leaflet-ugeojson
leaflet-ugeojson copied to clipboard
ugeojson and clustering
Hi
Is it possible yo use ugeojson and cluster points? I tried Leaflet.markercluster with ugeojson but i see 2 layers at the same time, the clustered one and the non-clustered. Here's what i tried:
var markers = L.markerClusterGroup();
lPoints=L.uGeoJSONLayer({endpoint:"getPoints.php", after: after}).addTo(map);
function after(data) {
markers.clearLayers();
markers.addLayer(lPoints);
map.addLayer(markers);
}
Any idea?
Have you tried something like this?
var markers = L.markerClusterGroup();
markers.addLayer(L.uGeoJSONLayer({endpoint:"getPoints.php"}))
map.addLayer(markers);
Le mar. 29 oct. 2019 à 10:30, geologic [email protected] a écrit :
Hi
Is it possible yo use ugeojson and cluster points? I tried Leaflet.markercluster with ugeojson but i see 2 layers at the same time, the clustered one and the non-clustered. Here's what i tried:
var markers = L.markerClusterGroup();
lPoints=L.uGeoJSONLayer({endpoint:"getPoints.php", after: after}).addTo(map);
function after(data) { markers.clearLayers(); markers.addLayer(lPoints); map.addLayer(markers); }
Any idea?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BenjaminVadant/leaflet-ugeojson/issues/15?email_source=notifications&email_token=AA7P3AHAEQ54HTZ4FS2V4JDQQ77B3A5CNFSM4JGFYQ6KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HU73M2Q, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7P3AENAF7UCTJ2KCVI62TQQ77B3ANCNFSM4JGFYQ6A .
Yes, i tried that first, but no points are rendered on map. With inspector i see that no request is made to getpoints.php
@geologic Did you ever find a fix?
Nope, i end giving up of clustering... If you find a way please let me know
Maybe it has something to do with the event I'm listening to to trigger the calls : I'm not using the "moveend" event as it triggers strange behavior : it can start an autocall loop! So I prefer to use dragend and zoomend.
This line https://github.com/Leaflet/Leaflet.markercluster/blob/93bf5408ad84b74ea42f55ccb6ca0450daa41427/src/MarkerClusterGroup.js#L577 shows that Leaflet.markercluster is relying on "moveend" to work.
I'll try to update (it has been a long time) the lib
After investigation, the issue is more complicated than I previously thought : my Leaflet.uGeoJSON layer relies on a call to the "onAdd" method which normally occurs when the layer is added to a map but not when it is added to the cluster group layer.
It will need a real refactor.
Does this mean it might not support it for quite some time?
Yes