How to cluster bunch of markers? #50
-
I have bunch of Simplified component example <MapLibre>
{#each $markers as marker (marker.id)}
<Marker lngLat={marker.position}>
<span>Hi</span>
</Marker>
{/each}
</MapLibre> The |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, it only supports MapLibre's built-in clustering functionality right now, which in turn only works with GeoJSON. The most straightforward way would be to convert the data to GeoJSON for display, which is basically a matter of converting to something like this: {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": marker.id,
"properties": { /* any additional props here, such as text to display, color, etc. */ },
"geometry": {
"type": "Point",
"coordinates": marker.position
}
},
// Additional markers here
]
} Libraries such as |
Beta Was this translation helpful? Give feedback.
No, it only supports MapLibre's built-in clustering functionality right now, which in turn only works with GeoJSON.
The most straightforward way would be to convert the data to GeoJSON for display, which is basically a matter of converting to something like this:
Libraries such as
turf
can take out some of the busyw…