From 82d4535180bcf43e1d32408e9c8ff215ecd36943 Mon Sep 17 00:00:00 2001 From: Roemer Vlasveld Date: Mon, 21 Jan 2013 22:36:24 +0100 Subject: [PATCH] Add hasLayer to LayerGroup Add the method hasLayer to LayerGroup, return false when not present or checking for a null layer. --- src/layer/LayerGroup.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/layer/LayerGroup.js b/src/layer/LayerGroup.js index b593b59e..3b0166a7 100644 --- a/src/layer/LayerGroup.js +++ b/src/layer/LayerGroup.js @@ -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;