zoomToShowLayer doesn't fire callback when using CircleMarkers
See original GitHub issueHow to reproduce
- Leaflet version I’m using: 1.3.1
- Leaflet.MarkerCluster version I’m using: 1.3.0
- Browser (with version) I’m using: Chrome 67.0.3396.87
- OS/Platform (with version) I’m using: macOS High Sierra
- Add three circle markers to the map (in my case, 2 in Hong Kong and 1 in the Phillipines - see example).
- Zoom out so all three markers cluster together.
- Call
zoomToShowLayer
passing the Phillipines marker.
What behaviour I’m expecting and which behaviour I’m seeing
Expecting the zoomToShowLayer
callback to be fired. It’s not fired because it’s checking for an icon on the marker before firing the callback, which doesn’t exist on a CircleMarker. The Hong Kong buttons because the parent (i.e. the cluster) has an icon.
if ((layer._icon || layer.__parent._icon) && !this._inZoomAnimation) {
Minimal example reproducing the issue
Clicking on Zoom to Marker 1
doesn’t open the popup.
http://jsfiddle.net/7cxwu248/28/
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Zoom in so a marker is visible in LeafletJS - Stack Overflow
zoomToShowLayer (layer, callback): Zooms to show the given marker (spiderfying if required), calls the callback when the marker is visible on ...
Read more >Leaflet.markercluster | Marker Clustering plugin for Leaflet
zoomToShowLayer (layer, callback): Zooms to show the given marker (spiderfying if required), calls the callback when the marker is visible on the map....
Read more >leaflet.markercluster-src.js in extensions/piwigo ...
//Removes all layers from the MarkerClusterGroup · clearLayers: function () { · //Need our own special implementation as the LayerGroup one doesn't work...
Read more >sardonyx test dashboard - Popular Blocks
in main div. might also use relative positioning here, for now assume ... addLayer(marker); }); }; /* Callback functions */ function ...
Read more >Changeset 315 for binary-improvements/webserver/leaflet
r173 r315
3 3 https://github.com/Leaflet/Leaflet.markercluster
4 (c) 2012‑201 3, Dave Leaver, smartrak
4 (c) 2012‑201 7, Dave Leaver
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
Seems that it works for spiderfied Circle Markers (i.e. Markers 2 and 3 in the provided example) because in that case the callback is executed once
"spiderfied"
event fires, whether the Layer has an_icon
or not. https://github.com/Leaflet/Leaflet.markercluster/blob/4cea2dfba189972c7ce06a0ab3cbc9cc8aa0b694/src/MarkerClusterGroup.js#L544-L556Since the check for
layer._icon
andlayer.__parent._icon
is to know whether they are visible (added) on map or not, we could simply usemap.hasLayer
instead (if it is not on map, it is collected in a cluster, or not part of this cluster group at all…)Updated JSFiddle: https://jsfiddle.net/7cxwu248/39/
BTW this is the same case on the next lines: https://github.com/Leaflet/Leaflet.markercluster/blob/4cea2dfba189972c7ce06a0ab3cbc9cc8aa0b694/src/MarkerClusterGroup.js#L558-L560 It is less of a problem, since in this case we move first then execute the callback, instead of just executing the callback.
I downloaded the sources and made my changes, I just realized this repo is not maintained anymore.