Add hasLayer to LayerGroup

Add the method hasLayer to LayerGroup, return false when not present or checking for a null layer.
This commit is contained in:
Roemer Vlasveld 2013-01-21 22:36:24 +01:00
parent a000304473
commit 82d4535180

View File

@ -40,6 +40,13 @@ L.LayerGroup = L.Class.extend({
return this;
},
hasLayer: function (layer) {
if (!layer) { return false; }
var id = L.stamp(layer);
return this._layers.hasOwnProperty(id);
}
clearLayers: function () {
this.eachLayer(this.removeLayer, this);
return this;