Update build.

This commit is contained in:
danzel
2012-09-03 10:35:13 +12:00
parent 374e74f78a
commit f65634943f
2 changed files with 23 additions and 4 deletions

View File

@@ -21,7 +21,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
zoomToBoundsOnClick: true, zoomToBoundsOnClick: true,
singleMarkerMode: false, singleMarkerMode: false,
disableClusteringAtZoom: null disableClusteringAtZoom: null,
skipDuplicateAddTesting: false
}, },
initialize: function (options) { initialize: function (options) {
@@ -40,8 +42,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
addLayer: function (layer) { addLayer: function (layer) {
if (layer instanceof L.LayerGroup) if (layer instanceof L.LayerGroup) {
{
for (var i in layer._layers) { for (var i in layer._layers) {
if (layer._layers.hasOwnProperty(i)) { if (layer._layers.hasOwnProperty(i)) {
this.addLayer(layer._layers[i]); this.addLayer(layer._layers[i]);
@@ -66,6 +67,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
return this; return this;
} }
if (!this.options.skipDuplicateAddTesting && this.hasLayer(layer)) {
return this;
}
//If we have already clustered we'll need to add this one to a cluster //If we have already clustered we'll need to add this one to a cluster
if (this._unspiderfy) { if (this._unspiderfy) {
@@ -117,6 +122,20 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
return this; return this;
}, },
hasLayer: function (layer) {
var res = false;
this._topClusterLevel._recursively(new L.LatLngBounds([layer.getLatLng()]), 0, this._map.getMaxZoom() + 1,
function (cluster) {
for (var i = cluster._markers.length - 1; i >= 0 && !res; i--) {
if (cluster._markers[i] === layer) {
res = true;
}
}
}, null);
return res;
},
//Overrides FeatureGroup.onAdd //Overrides FeatureGroup.onAdd
onAdd: function (map) { onAdd: function (map) {
L.FeatureGroup.prototype.onAdd.call(this, map); L.FeatureGroup.prototype.onAdd.call(this, map);

View File

File diff suppressed because one or more lines are too long