Update build

This commit is contained in:
danzel
2012-09-06 16:20:02 +12:00
parent dc16362b6c
commit 7ae3e1ad42
2 changed files with 24 additions and 10 deletions
+23 -9
View File
@@ -23,7 +23,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
disableClusteringAtZoom: null,
skipDuplicateAddTesting: false
skipDuplicateAddTesting: false,
//Whether to animate adding markers after adding the MarkerClusterGroup to the map
// If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains.
animateAddingMarkers: false
},
initialize: function (options) {
@@ -79,8 +83,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
var newCluster = this._topClusterLevel._recursivelyAddLayer(layer, this._topClusterLevel._zoom - 1);
this._animationAddLayer(layer, newCluster);
if (this.options.animateAddingMarkers) {
this._animationAddLayer(layer, newCluster);
} else {
this._animationAddLayerNonAnimated(layer, newCluster);
}
return this;
},
@@ -432,6 +439,16 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
ne = map.unproject(new L.Point(bounds.max.x + width, bounds.max.y + height));
return new L.LatLngBounds(sw, ne);
},
//Shared animation code
_animationAddLayerNonAnimated: function (layer, newCluster) {
if (newCluster === true) {
L.FeatureGroup.prototype.addLayer.call(this, layer);
} else if (newCluster._childCount === 2) {
newCluster._addToMap();
newCluster._recursivelyRemoveChildrenFromMap(newCluster._bounds, this._map.getMaxZoom()); //getMaxZoom will always get all children
}
}
});
@@ -450,12 +467,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel - this._topClusterLevel._zoom + 1, this._getExpandedVisibleBounds());
},
_animationAddLayer: function (layer, newCluster) {
if (newCluster === true) {
L.FeatureGroup.prototype.addLayer.call(this, layer);
} else if (newCluster._childCount === 2) {
newCluster._addToMap();
newCluster._recursivelyRemoveChildrenFromMap(newCluster._bounds, this._map.getMaxZoom()); //getMaxZoom will always get all children
}
this._animationAddLayerNonAnimated(layer, newCluster);
}
} : {
@@ -1664,6 +1676,8 @@ L.MarkerClusterGroup.include({
this._map.off('click', this._unspiderfyWrapper, this);
this._map.off('zoomstart', this._unspiderfyZoomStart, this);
this._map.off('zoomanim', this._unspiderfyZoomAnim, this);
this._unspiderfy(); //Ensure that markers are back where they should be
},
+1 -1
View File
File diff suppressed because one or more lines are too long