Fix up removing a marker from the map while it is spiderfied. Fix up a place where markers were left with opacity 0.

This commit is contained in:
danzel
2012-07-27 15:21:02 +12:00
parent a446eb82bc
commit ea5428ebfb
2 changed files with 20 additions and 0 deletions
+18
View File
@@ -256,6 +256,13 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
setTimeout(function () {
for (i = childMarkers.length - 1; i >= 0; i--) {
m = childMarkers[i];
if (!m._spiderLeg) { //Has already been unspiderfied
continue;
}
m.setOpacity(1);
m.setZIndexOffset(0);
L.FeatureGroup.prototype.removeLayer.call(group, m);
@@ -287,5 +294,16 @@ L.MarkerClusterGroup.include({
if (this._spiderfied) {
this._spiderfied.unspiderfy();
}
},
//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) {
L.FeatureGroup.prototype.removeLayer.call(this, layer);
layer.setOpacity(1);
layer.setZIndexOffset(0);
this._map.removeLayer(layer._spiderLeg);
delete layer._spiderLeg;
}
}
});
+2
View File
@@ -50,6 +50,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
removeLayer: function (layer) {
if (this._unspiderfy) {
this._unspiderfy();
this._unspiderfyLayer(layer);
}
if (!this._topClusterLevel._recursivelyRemoveLayer(layer)) {
@@ -477,6 +478,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
setTimeout(function () {
L.FeatureGroup.prototype.removeLayer.call(me, layer);
layer.setOpacity(1);
me._animationEnd();
}, 250);