groups cleanup; fix getBounds when containing CircleMarkers

This commit is contained in:
Vladimir Agafonkin 2013-12-05 21:27:40 +02:00
parent eeaec502ac
commit edca4a6075
3 changed files with 4 additions and 10 deletions

View File

@ -14,9 +14,7 @@ L.FeatureGroup = L.LayerGroup.extend({
return this;
}
if ('on' in layer) {
layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);
}
layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);
L.LayerGroup.prototype.addLayer.call(this, layer);
@ -77,7 +75,7 @@ L.FeatureGroup = L.LayerGroup.extend({
var bounds = new L.LatLngBounds();
this.eachLayer(function (layer) {
bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds());
bounds.extend((layer.getBounds || layer.getLatLng)());
});
return bounds;

View File

@ -42,9 +42,7 @@ L.LayerGroup = L.Layer.extend({
},
hasLayer: function (layer) {
if (!layer) { return false; }
return (layer in this._layers || this.getLayerId(layer) in this._layers);
return !layer || layer in this._layers || this.getLayerId(layer) in this._layers;
},
clearLayers: function () {

View File

@ -161,9 +161,7 @@ L.Map = L.Class.extend({
},
hasLayer: function (layer) {
if (!layer) { return false; }
return (L.stamp(layer) in this._layers);
return !layer || L.stamp(layer) in this._layers;
},
eachLayer: function (method, context) {