Leaflet.markercluster icon indicating copy to clipboard operation
Leaflet.markercluster copied to clipboard

Error thrown when clustering after leaflet flyToBounds() function. Reproduced in jsFiddle

Open guanzo opened this issue 8 years ago • 4 comments

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:

  1. Open dev console (i'm using chrome)
  2. Click the zoom button.
  3. 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/

guanzo avatar Dec 06 '16 18:12 guanzo

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.

amiiit avatar Dec 29 '16 18:12 amiiit

Done. https://jsfiddle.net/k4b56h79/14/

This is related to #743, if i remove the chunkedLoading option, the error disappears.

guanzo avatar Jan 02 '17 09:01 guanzo

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?

amiiit avatar Jan 04 '17 16:01 amiiit

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).

Screenshot 2019-10-14 at 11 44 24

stereobooster avatar Oct 14 '19 10:10 stereobooster