{
const initialViewState = {
longitude: 0,
latitude: 10,
zoom: 1.5,
pitch: 45,
};
const container = document.createElement("div");
container.setAttribute(
"style",
"position: relative; height: 500px; width: 800px;",
);
const deck = (
await import("https://cdn.jsdelivr.net/npm/deck.gl/dist.min.js/+esm")
).default;
const maplibregl = (
await import("https://cdn.jsdelivr.net/npm/maplibre-gl@5.6.0/+esm")
).default;
const colorsRGB = [
[255, 255, 204],
[199, 233, 180],
[127, 205, 187],
[65, 182, 196],
[29, 145, 192],
[34, 94, 168],
[12, 44, 132],
];
const scale = d3
.scaleQuantile()
.domain(input.map((d) => d.VALUE))
.range(colorsRGB);
const getColor = (n) => {
const baseColor = scale(n);
return [...baseColor, 150];
};
const arcLayer = new deck.ArcLayer({
id: "arc-layer",
data: input,
getSourcePosition: (d) => [d.STARTLON, d.STARTLAT],
getTargetPosition: (d) => [d.ENDLON, d.ENDLAT],
getSourceColor: (d) => getColor(d.VALUE),
getTargetColor: (d) => getColor(d.VALUE),
getWidth: 1,
pickable: true,
greatCircle: false,
});
new deck.DeckGL({
map: maplibregl,
container,
mapStyle: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
initialViewState,
controller: true,
layers: [arcLayer],
});
return container;
}