Sha256: 9d6459afbd7581cd16ed419ef1ed55d98a33c2a5fb0ea34786ad7c4a442035d9
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
/* * L.LayerGroup is a class to combine several layers so you can manipulate the group (e.g. add/remove it) as one layer. */ L.LayerGroup = L.Class.extend({ initialize: function (layers) { this._layers = {}; if (layers) { for (var i = 0, len = layers.length; i < len; i++) { this.addLayer(layers[i]); } } }, addLayer: function (layer) { var id = L.Util.stamp(layer); this._layers[id] = layer; if (this._map) { this._map.addLayer(layer); } return this; }, removeLayer: function (layer) { var id = L.Util.stamp(layer); delete this._layers[id]; if (this._map) { this._map.removeLayer(layer); } return this; }, clearLayers: function () { this._iterateLayers(this.removeLayer, this); return this; }, invoke: function (methodName) { var args = Array.prototype.slice.call(arguments, 1), i, layer; for (i in this._layers) { if (this._layers.hasOwnProperty(i)) { layer = this._layers[i]; if (layer[methodName]) { layer[methodName].apply(layer, args); } } } return this; }, onAdd: function (map) { this._map = map; this._iterateLayers(map.addLayer, map); }, onRemove: function (map) { this._iterateLayers(map.removeLayer, map); delete this._map; }, _iterateLayers: function (method, context) { for (var i in this._layers) { if (this._layers.hasOwnProperty(i)) { method.call(context, this._layers[i]); } } } });
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
leaflet-ruby-0.3.beta4 | lib/leaflet/src/layer/LayerGroup.js |
leaflet-ruby-0.3.beta3 | lib/leaflet/src/layer/LayerGroup.js |
leaflet-ruby-0.3.beta1 | lib/leaflet/src/layer/LayerGroup.js |