render = (container, map) => {
const pixelbbox = container.getBoundingClientRect();
const width = pixelbbox.width;
const height = pixelbbox.height;
const geobbox = map.getBounds();
const projectPoint = ([x, y]) => [
((x - geobbox._sw.lng) / (geobbox._ne.lng - geobbox._sw.lng)) * width,
height -
((y - geobbox._sw.lat) / (geobbox._ne.lat - geobbox._sw.lat)) * height
];
const points = stations.map(([x, y]) => projectPoint([x, y]));
const delaunay = d3.Delaunay.from(points);
const voronoi = delaunay.voronoi([0.5, 0.5, width - 0.5, height - 0.5]);
const voronoiPath = voronoi.render();
let canvasContainer = map.getCanvasContainer();
d3.select("svg").remove();
let svg = d3
.select(canvasContainer)
.append("svg")
.attr("width", width)
.attr("height", height);
svg.attr("style", "position: relative;");
let pathSvg = svg
.append("path")
.attr("d", voronoiPath)
.attr("stroke", fuelType.color)
.attr("stroke-width", 0.5);
points.map(([x, y]) =>
svg
.append("circle")
.attr("cx", x)
.attr("cy", y)
.attr("r", 2)
.attr("fill", fuelType.color)
);
}