Fix for new bug on #286

This commit is contained in:
danzel
2014-04-15 12:02:10 +12:00
parent 332c5f897d
commit 339ee4abeb
2 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ L.MarkerCluster = L.Marker.extend({
mapZoom = map.getZoom(),
i;
//calculate how fare we need to zoom down to see all of the markers
//calculate how far we need to zoom down to see all of the markers
while (childClusters.length > 0 && boundsZoom > zoom) {
zoom++;
var newClusters = [];
+13 -2
View File
@@ -423,16 +423,27 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
};
if (layer._icon && this._map.getBounds().contains(layer.getLatLng())) {
//Layer is visible ond on screen, immediate return
callback();
} else if (layer.__parent._zoom < this._map.getZoom()) {
//Layer should be visible now but isn't on screen, just pan over to it
//Layer should be visible at this zoom level. It must not be on screen so just pan over to it
this._map.on('moveend', showMarker, this);
this._map.panTo(layer.getLatLng());
} else {
var moveStart = function () {
this._map.off('movestart', moveStart, this);
moveStart = null;
};
this._map.on('movestart', moveStart, this);
this._map.on('moveend', showMarker, this);
this.on('animationend', showMarker, this);
this._map.setView(layer.getLatLng(), layer.__parent._zoom + 1);
layer.__parent.zoomToBounds();
if (moveStart) {
//Never started moving, must already be there, probably need clustering however
showMarker.call(this);
}
}
},