viewof map = {
const container = html`<div style="height:600px;">`;
yield container;
const map = (container.value = new mapboxgl.Map({
container,
center: pointsData.features[0].geometry.coordinates,
zoom: 10,
style: "mapbox://styles/jguerrag/cjuerw13z2vja1fndc9wzk7eo",
scrollZoom: true
}));
const bb = container.getBoundingClientRect();
var svg = d3
.select(container)
.append("svg")
.style("position", "absolute")
.style("top", 0)
.style("left", 0)
.attr("width", bb.width)
.attr("height", bb.height)
.style("pointer-events", "none");
function projectPoint(lon, lat) {
var point = map.project(new mapboxgl.LngLat(lon, lat));
this.stream.point(point.x, point.y);
}
var transform = d3.geoTransform({ point: projectPoint });
var path = d3.geoPath().projection(transform);
const dots = svg
.selectAll(".puesto")
.data(pointsData.features)
.join("path")
.attr("class", "puesto")
.style("fill", "salmon")
.on("mouseover", d => (mutable hovered = d))
.style("pointer-events", "all");
const update = () => {
dots.attr("d", path);
};
map.on("viewreset", update);
map.on("move", update);
map.on("moveend", update);
invalidation.then(() => {
map.off("viewreset", update);
map.off("move", update);
map.off("moveend", update);
map.remove();
});
update();
}