PruneCluster
PruneCluster copied to clipboard
FitBounds does not work, if map view is not already set
Hello,
I get this error when I call FitBounds and map's view is not predefined or set yet.
I have to call map.setView(latlng)
before using fitBounds, but what I actually want is to set and fit map view and zoom to marker bounds.
Btw, it works well when I do the work myself like this:
var bounds = pruneCluster.Cluster.ComputeGlobalBounds();
if (bounds) {
map.fitBounds(new L.LatLngBounds(new L.LatLng(bounds.minLat, bounds.maxLng), new L.LatLng(bounds.maxLat, bounds.minLng)));
}
Hei,
It looks like this._map
is undefined. It is defined when you add the PruneCluster layer to your map. Do you call FitBounds
before adding the layer ?
No, PruneCluster layer is already added. I will prepare a html file if you can not reproduce.
Yes, that will be helpful.