From f0b1618e0700bba1dc3d951417c7debfb440b931 Mon Sep 17 00:00:00 2001 From: danzel Date: Thu, 19 Dec 2013 16:03:55 +1300 Subject: [PATCH] Fix some cases where zoomToShowLayer wouldn't work. Fixes #286 #228 #203 --- src/MarkerClusterGroup.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 8d3502aac..7f8f0fb1a 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -378,14 +378,12 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ } }; - if (layer._icon) { + if (layer._icon && this._map.getBounds().contains(layer.getLatLng())) { callback(); } else if (layer.__parent._zoom < this._map.getZoom()) { //Layer should be visible now but isn't on screen, just pan over to it this._map.on('moveend', showMarker, this); - if (!layer._icon) { - this._map.panTo(layer.getLatLng()); - } + this._map.panTo(layer.getLatLng()); } else { this._map.on('moveend', showMarker, this); this.on('animationend', showMarker, this);