Leaflet.markercluster
Leaflet.markercluster copied to clipboard
Error thrown when clustering after leaflet flyToBounds() function. Reproduced in jsFiddle
jsFiddle: https://jsfiddle.net/k4b56h79/14/
Problem: I use leaflets flyToBounds function, and attach a listener for the zoomend
event. In the event callback, i add a cluster of markers to the map. I get an error message Uncaught TypeError: Cannot read property 'lat' of undefined
.
Steps to reproduce:
- Open dev console (i'm using chrome)
- Click the zoom button.
- Click the world button.
The error should be thrown by now, if not, repeat steps 2 and 3.
I've managed a workaround by wrapping the zoomend
callback with a 50 ms timeout, like so
https://jsfiddle.net/guanzo/k4b56h79/12/
It also works if i remove the flyToBounds function entirely. https://jsfiddle.net/guanzo/k4b56h79/13/
In the given fiddle, could you please replace the sources fromleaflet.js
and leaflet.markercluster.js
with leaflet-src.js
and leaflet.markercluster-src.js
accordingly? This will allow to do some debugging in the console.
Done. https://jsfiddle.net/k4b56h79/14/
This is related to #743, if i remove the chunkedLoading option, the error disappears.
For what it's worth and without knowing the code too well, it seems to me that the Infinity
value that causes the error starts here:
https://github.com/Leaflet/Leaflet.markercluster/blob/7db30166f0be49ea20f778671ba1ed6ac047ddfd/src/MarkerClusterGroup.js#L1019
Is there anyone here that knows more about it that can help investigate this?
Have similar error. https://github.com/YUzhva/react-leaflet-markercluster/issues/71#issuecomment-541128929
execution gets to this point:
function toLatLngBounds(a, b) {
if (a instanceof LatLngBounds) {
return a;
}
return new LatLngBounds(a, b);
}
where a
is LatLngBounds
(it has all the same methods), but it is not instance of LatLngBounds
(it identifies itself as B
).
