Leaflet.markercluster
Leaflet.markercluster copied to clipboard
Infinite loop created when Leaflet returns "Infinity" from getMaxZoom
- [X] I'm reporting a bug, not asking for help
- [X] I'm sure this is a Leaflet.MarkerCluster code issue, not an issue with my own code nor with the framework I'm using (Cordova, Ionic, Angular, React…)
- [X] I've searched through the issues to make sure it's not yet reported
How to reproduce
- Leaflet version I'm using: 1.2
- Leaflet.MarkerCluster version I'm using:
- Browser (with version) I'm using: Chrome 66.0.3359.181
- OS/Platform (with version) I'm using: Windows 10
- To reproduce, create a leaflet map instance that reports "Infinity" from the call to getMaxZoom on the leaflet map.
What behaviour I'm expecting and which behaviour I'm seeing
If Leaflet returns "Infinity" from the call to getMaxZoom, the for loop in the _generateInitialClusters function will loop infinity. Since the decrementor will never decrement Infinity, the loop continues endlessly and will lock up the web application. While there might be an issue in Leaflet that causes getMaxZoom to return Infinity, a check for that condition could be added to this library to prevent the infinite loop.
Minimal example reproducing the issue
- [ ] this example is as simple as possible
- [ ] this example does not rely on any third party code
Using http://leafletjs.com/edit.html or any other jsfiddle-like site.
Would accept a PR that threw an error instead of the loop to infinity :+1:
Sounds good...I'll work something up and issue one. Thanks!