I am trying to show the hexagons all over the world, (at least all over India) using H3 on my Leaflet map. I have tried the below logic but it doesn't work:
Logic:
const boundingBoxIndia = [
[38.11727165830543, 76.37695312500001],
[23.785344805941214, 67.41210937500001],
[6.293458760393985, 77.16796875000001],
[28.51696944040106, 98.525390625],
];
const cellIdsInIndia = h3.polyfill(boundingBoxIndia, 13, true);
const hexagonsInIndia = [];
const hexagonInIndia = cellIdsInIndia?.map((cellId, i) => {
const polygon = h3.h3ToGeoBoundary(cellId, false);
return [polygon];
});
hexagonsInIndia.push(hexagonInIndia);
In render:
<IndiaCells cellGroups={hexagonsInIndia} />
Component
const IndiaCells = (props) => {
if (props.cellGroups?.length) {
return props.cellGroups.map((cells, index) => {
return cells.map(([polygon], groupIndex) => {
return (
<div key={groupIndex}>
<Polygon
positions={polygon}
pathOptions={{...}}
></Polygon>
</div>
);
});
});
} else {
return null;
}
};
I am able to render other hexagons for a smaller sample by the same logic. Also the above code takes a lot of time to load the map but hexagons aren't visible. Looks like size might be an issue here. Is there any better way to show the H3 hexagon grids all over the map? Something like this: