selectedLayer = {
const allhex = points.features
.filter((d) => d.properties.selected)
.map((d) => {
const [lng, lat] = d.geometry.coordinates;
return h3.latLngToCell(lat, lng, h3res);
})
.reduce((layer, hex) => {
if (layer[hex]) {
layer[hex] += 1;
} else {
layer[hex] = 1;
}
return layer;
}, {});
const max = d3.max(Object.values(allhex));
const min = d3.min(Object.values(allhex));
return Object.fromEntries(
Object.entries(allhex).map(([hex, value]) => [
hex,
(value - min) / (max - min)
])
);
}