emilhe / dash-leaflet

MIT License
213 stars 37 forks source link

GeoJSON + Cluster breaks when changing geometry types #152

Closed Lkruitwagen closed 1 year ago

Lkruitwagen commented 2 years ago

Hi all!

I'm building a map that dynamically visualises GeoJSON by calling an API as the user pans and zooms. An API is called that returns geobuf, simplified based on the zoom level, and clipped to the current map bounds plus some buffer. If the user pans beyond the buffer, the data is refreshed, otherwise the current data is passed through. I've implemented this in clientside callbacks for efficiency, like a bit of a hacky vector server (#84).

The Problem: If both geojson.data and geojson.cluster are the outputs of callbacks, Polygon data is re-rended as points on a map pan event (a small pan within the bounds that doesn't trigger a fresh API call). If I disable clustering entirely I get the desired zoom and pan behaviour, just without the beautiful clustering.

I've also tried making geojson.cluster an input to the geojson.data callback (presumably so as a dependency it finishes first) but no luck!

Is this a bug?

https://user-images.githubusercontent.com/22874837/185195665-b60bbea9-fa43-46d6-8597-0f3b4848e129.mp4

emilhe commented 1 year ago

I believe this should work in 1.0.2. Please re-open this issue if it doesn't.