New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception adding layer when map has a non-integer max-zoom. #789
Comments
Can we have a playground example or a unit test to reproduce this please? |
here you go. I literally did nothing other than update the markercluster version number and add the maxZoom field to the map configuration object. thanks, |
sorry, closed by accident |
Do you need anything further from me on this? |
https://gist.github.com/danzel/912c140d879f82518bd9f13e0648a2b3 |
While it does fix the initial exception, I think you need to do something similar in _addLayer as well since that also accesses the gridClusters and gridUnclustered arrays. Cheers. |
lol thanks, on it! |
Ok changed. Please try that and report back! Thanks. |
Thanks Danzel, |
1.0.6 released with this included |
How to reproduce
Create a leaflet map and specify an non-integer maxZoom in the options.
var mapOptions = {maxZoom: 16.5, zoomControl: false, attributionControl: false, constrainLon: false};
this.MapObj = leaflet.map(mapId, mapOptions);
Later after adding a layer to the map, marker cluster gets into the MarkerClusterGroup._addLayer method. this fails when it tries to reference gridClusters 1.5 (note the minZoom is 2 in this case).
What behaviour I'm expecting and which behaviour I'm seeing
Exception as follows:
TypeError: Cannot read property 'addObject' of undefined
at NewClass._addLayer (leaflet.markercluster.js:1002)
at NewClass. (leaflet.markercluster.js:253)
at NewClass.addLayers (leaflet.markercluster.js:287)
at NewClass.onAdd (leaflet.markercluster.js:624)
at NewClass._layerAdd (ng-geobase-map.js:17383)
at NewClass.whenReady (ng-geobase-map.js:17025)
at NewClass.addLayer (ng-geobase-map.js:17441)
at InsightsMap.SetLayerVisibility (geobaseMap.js:466)
at addMarkers (geobaseMap.js:756)
at Scope.$digest (ionic.bundle.js:30244)
(anonymous) @ ionic.bundle.js:26799
Minimal example reproducing the issue
This seems to be a discrepency between the code in _generateInitialClusters and _addLayers. It looks as if _generateInitialClusters created the distances grids it needs, and then expects this line
this._topClusterLevel = new this._markerCluster(this, minZoom - 1);
to create the final level. In this case minZoom is 2 so it makes level 1, whereas it should have actually created level 1.5 (local var zoom -1). This is what the _addLayer code expects to see when it dereferences the array in line
gridClusters[z].addObject(lastParent, this._map.project(closest.getLatLng(), z));
Sorry, haven't had time to work up an example for you, but hopefully it will be trivial given the information above. let me know if you really need me to provide a reproducer.
thanks,
The text was updated successfully, but these errors were encountered: