leaflet-ugeojson icon indicating copy to clipboard operation
leaflet-ugeojson copied to clipboard

ugeojson and clustering

Open geologic opened this issue 6 years ago • 8 comments
trafficstars

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?

geologic avatar Oct 29 '19 09:10 geologic

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 .

BenjaminVadant avatar Oct 29 '19 17:10 BenjaminVadant

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 avatar Oct 29 '19 18:10 geologic

@geologic Did you ever find a fix?

KieranFletcher avatar Feb 25 '21 00:02 KieranFletcher

Nope, i end giving up of clustering... If you find a way please let me know

geologic avatar Feb 25 '21 08:02 geologic

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

BenjaminVadant avatar Feb 25 '21 09:02 BenjaminVadant

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.

BenjaminVadant avatar Feb 25 '21 14:02 BenjaminVadant

Does this mean it might not support it for quite some time?

KieranFletcher avatar Feb 25 '21 15:02 KieranFletcher

Yes

BenjaminVadant avatar Feb 25 '21 16:02 BenjaminVadant