Fix clearLayers with spiderfied markers. Refs #162

This commit is contained in:
danzel
2013-04-24 10:44:46 +12:00
parent d387694ce5
commit 890406abd6
2 changed files with 34 additions and 20 deletions
+32 -18
View File
@@ -83,6 +83,31 @@ L.MarkerCluster.include({
legLength += this._2PI * lengthFactor / angle;
}
return res;
},
_noanimationUnspiderfy: function () {
var group = this._group,
map = group._map,
childMarkers = this.getAllChildMarkers(),
m, i;
this.setOpacity(1);
for (i = childMarkers.length - 1; i >= 0; i--) {
m = childMarkers[i];
L.FeatureGroup.prototype.removeLayer.call(group, m);
if (m._preSpiderfyLatlng) {
m.setLatLng(m._preSpiderfyLatlng);
delete m._preSpiderfyLatlng;
}
m.setZIndexOffset(0);
if (m._spiderLeg) {
map.removeLayer(m._spiderLeg);
delete m._spiderLeg;
}
}
}
});
@@ -113,24 +138,7 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
},
_animationUnspiderfy: function () {
var group = this._group,
map = group._map,
childMarkers = this.getAllChildMarkers(),
m, i;
this.setOpacity(1);
for (i = childMarkers.length - 1; i >= 0; i--) {
m = childMarkers[i];
L.FeatureGroup.prototype.removeLayer.call(group, m);
m.setLatLng(m._preSpiderfyLatlng);
delete m._preSpiderfyLatlng;
m.setZIndexOffset(0);
map.removeLayer(m._spiderLeg);
delete m._spiderLeg;
}
this._noanimationUnspiderfy();
}
} : {
//Animated versions here
@@ -378,6 +386,12 @@ L.MarkerClusterGroup.include({
}
},
_noanimationUnspiderfy: function () {
if (this._spiderfied) {
this._spiderfied._noanimationUnspiderfy();
}
},
//If the given layer is currently being spiderfied then we unspiderfy it so it isn't on the map anymore etc
_unspiderfyLayer: function (layer) {
if (layer._spiderLeg) {
+2 -2
View File
@@ -214,8 +214,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
delete this._gridUnclustered;
}
if (this._unspiderfy) {
this._unspiderfy();
if (this._noanimationUnspiderfy) {
this._noanimationUnspiderfy();
}
//Remove all the visible layers