Support being added and removed to the map

This commit is contained in:
danzel
2012-07-30 11:59:05 +12:00
parent f0414083dd
commit e0d2616925
2 changed files with 19 additions and 1 deletions
+4
View File
@@ -302,6 +302,10 @@ L.MarkerClusterGroup.include({
}
},
_spiderfierOnRemove: function () {
this._map.off('click zoomstart', this._unspiderfy, this);
},
_unspiderfy: function () {
if (this._spiderfied) {
this._spiderfied.unspiderfy();
+15 -1
View File
@@ -67,7 +67,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
onAdd: function (map) {
L.FeatureGroup.prototype.onAdd.call(this, map);
this._generateInitialClusters();
if (!this._topClusterLevel) {
this._generateInitialClusters();
}
this._map.on('zoomend', this._zoomEnd, this);
this._map.on('moveend', this._moveEnd, this);
@@ -78,6 +80,18 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
this._bindEvents();
},
//Overrides FeatureGroup.onRemove
onRemove: function (map) {
this._map.off('zoomend', this._zoomEnd, this);
this._map.off('moveend', this._moveEnd, this);
if (this._spiderfierOnRemove) { //TODO FIXME: Not sure how to have spiderfier add something on here nicely
this._spiderfierOnRemove();
}
L.FeatureGroup.prototype.onRemove.call(this, map);
},
//Overrides FeatureGroup._propagateEvent
_propagateEvent: function (e) {
if (e.target instanceof L.MarkerCluster) {