summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/leaflet.js/layer/FeatureGroup.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:24:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:24:15 +0000
commitf7fa67dcc49b0b50ae2323b13facac69f2b5e495 (patch)
treeb57cfa4095263521138ba8d3b372d91d99487a3e /debian/missing-sources/leaflet.js/layer/FeatureGroup.js
parentAdding upstream version 1.1.0. (diff)
downloadicingaweb2-module-map-debian/1.1.0-4.tar.xz
icingaweb2-module-map-debian/1.1.0-4.zip
Adding debian version 1.1.0-4.debian/1.1.0-4debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/missing-sources/leaflet.js/layer/FeatureGroup.js')
-rw-r--r--debian/missing-sources/leaflet.js/layer/FeatureGroup.js94
1 files changed, 94 insertions, 0 deletions
diff --git a/debian/missing-sources/leaflet.js/layer/FeatureGroup.js b/debian/missing-sources/leaflet.js/layer/FeatureGroup.js
new file mode 100644
index 0000000..5913ff9
--- /dev/null
+++ b/debian/missing-sources/leaflet.js/layer/FeatureGroup.js
@@ -0,0 +1,94 @@
+import {LayerGroup} from './LayerGroup';
+import {LatLngBounds} from '../geo/LatLngBounds';
+
+/*
+ * @class FeatureGroup
+ * @aka L.FeatureGroup
+ * @inherits LayerGroup
+ *
+ * Extended `LayerGroup` that makes it easier to do the same thing to all its member layers:
+ * * [`bindPopup`](#layer-bindpopup) binds a popup to all of the layers at once (likewise with [`bindTooltip`](#layer-bindtooltip))
+ * * Events are propagated to the `FeatureGroup`, so if the group has an event
+ * handler, it will handle events from any of the layers. This includes mouse events
+ * and custom events.
+ * * Has `layeradd` and `layerremove` events
+ *
+ * @example
+ *
+ * ```js
+ * L.featureGroup([marker1, marker2, polyline])
+ * .bindPopup('Hello world!')
+ * .on('click', function() { alert('Clicked on a member of the group!'); })
+ * .addTo(map);
+ * ```
+ */
+
+export var FeatureGroup = LayerGroup.extend({
+
+ addLayer: function (layer) {
+ if (this.hasLayer(layer)) {
+ return this;
+ }
+
+ layer.addEventParent(this);
+
+ LayerGroup.prototype.addLayer.call(this, layer);
+
+ // @event layeradd: LayerEvent
+ // Fired when a layer is added to this `FeatureGroup`
+ return this.fire('layeradd', {layer: layer});
+ },
+
+ removeLayer: function (layer) {
+ if (!this.hasLayer(layer)) {
+ return this;
+ }
+ if (layer in this._layers) {
+ layer = this._layers[layer];
+ }
+
+ layer.removeEventParent(this);
+
+ LayerGroup.prototype.removeLayer.call(this, layer);
+
+ // @event layerremove: LayerEvent
+ // Fired when a layer is removed from this `FeatureGroup`
+ return this.fire('layerremove', {layer: layer});
+ },
+
+ // @method setStyle(style: Path options): this
+ // Sets the given path options to each layer of the group that has a `setStyle` method.
+ setStyle: function (style) {
+ return this.invoke('setStyle', style);
+ },
+
+ // @method bringToFront(): this
+ // Brings the layer group to the top of all other layers
+ bringToFront: function () {
+ return this.invoke('bringToFront');
+ },
+
+ // @method bringToBack(): this
+ // Brings the layer group to the back of all other layers
+ bringToBack: function () {
+ return this.invoke('bringToBack');
+ },
+
+ // @method getBounds(): LatLngBounds
+ // Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).
+ getBounds: function () {
+ var bounds = new LatLngBounds();
+
+ for (var id in this._layers) {
+ var layer = this._layers[id];
+ bounds.extend(layer.getBounds ? layer.getBounds() : layer.getLatLng());
+ }
+ return bounds;
+ }
+});
+
+// @factory L.featureGroup(layers: Layer[])
+// Create a feature group, optionally given an initial set of layers.
+export var featureGroup = function (layers) {
+ return new FeatureGroup(layers);
+};