fix(zoomAnim): check on map with hasLayer

instead of _icon, so that it becomes compatible with non-icon-based Markers and Cluster Markers.
This commit is contained in:
ghybs
2018-10-09 09:54:54 +04:00
parent 983a8b0de7
commit f49f38c264

View File

@ -541,16 +541,20 @@ export var MarkerClusterGroup = L.MarkerClusterGroup = L.FeatureGroup.extend({
//Zoom down to show the given layer (spiderfying if necessary) then calls the callback
zoomToShowLayer: function (layer, callback) {
var map = this._map;
if (typeof callback !== 'function') {
callback = function () {};
}
var showMarker = function () {
if ((layer._icon || layer.__parent._icon) && !this._inZoomAnimation) {
// Assumes that map.hasLayer checks for direct appearance on map, not recursively calling
// hasLayer on Layer Groups that are on map (typically not calling this MarkerClusterGroup.hasLayer, which would always return true)
if ((map.hasLayer(layer) || map.hasLayer(layer.__parent)) && !this._inZoomAnimation) {
this._map.off('moveend', showMarker, this);
this.off('animationend', showMarker, this);
if (layer._icon) {
if (map.hasLayer(layer)) {
callback();
} else if (layer.__parent._icon) {
this.once('spiderfied', callback, this);