We am looking for a solution for the issue also described at [[LINK href="https://github.com/Leaflet/Leaflet.markercluster/issues/611"]]https://github.com/Leaflet/Leaflet.markercluster/issues/611[[/LINK]] respectively [[LINK href="https://github.com/shramov/leaflet-plugins/issues/200"]]https://github.com/shramov/leaflet-plugins/issues/200[[/LINK]]
We think a possible solution could be to hock into an event (like [[LINK href="http://leafletjs.com/reference.html#map-load"]]http://leafletjs.com/reference.html#map-load[[/LINK]]) and only add the markercluster once this event has been fired. Anyway we didnt come to a solution yet here.
We succeeded in a workaround by adding a timeout-function like
setTimeout(function(){...},1000); });
anyway solutions like that one are not qualified for a fix, as leaflet markercluster load fine on OpenStreetMap based maps for example and would delay the loading of markersclusters there too by 1 second for example.
Any help here would be appreciated!
Ross Wilson answers:
I played with this for a little bit and by far the simplest example is to add the maxZoom when you initialize the map, like in this fiddle
[[LINK href="http://jsfiddle.net/wSytj/157/"]]http://jsfiddle.net/wSytj/157/[[/LINK]]
Other than that, if you want to use the load event, you will have to just initialize the map without the coordinates and zoom, set the event, then initialize the map. Like I said, the example above is much simpler/cleaner
Robert Seyfriedsberger comments:
thx for prompt reply - anyway I am not sure if that would work within the context of the implementation in my plugins (see sourcecode at https://www.mapsmarker.com/dev/pro/2015/12/01/osm-mlm-load-all-markers/ for an example). This is why I was initially looking for a solution based on events fired after map is available.
Anyway will check your suggestion & get back to you - if you could also have a look at the URL above to check if your solution would work here too, that would be great!
Ross Wilson comments:
I don't have the full view into your code, but it looks like you should be able to apply the same fix, passing a default of maxZoom: 1 into the object passed into new L.map(), the same place where you pass all the other options to the customized map in your plugin. In the page you linked above, it would be the same object where you are passing touchZoom: true, etc