aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/src/layer/FeatureGroup.js
diff options
context:
space:
mode:
authorAditi <aditi.iitr@gmail.com>2013-06-21 23:09:22 +0530
committerAditi <aditi.iitr@gmail.com>2013-06-21 23:09:22 +0530
commit2719d546a57c2332e36cc056ac80ec5d79672c1a (patch)
tree1f62ab8f761026d4faa5442032df133fc90d47f2 /extlib/leaflet/src/layer/FeatureGroup.js
parent1a6f065419290b3f4234ce4a89bb2c46b13e8a12 (diff)
parent92b22e7deac547835f69168f97012b52e87b6de4 (diff)
downloadmediagoblin-2719d546a57c2332e36cc056ac80ec5d79672c1a.tar.lz
mediagoblin-2719d546a57c2332e36cc056ac80ec5d79672c1a.tar.xz
mediagoblin-2719d546a57c2332e36cc056ac80ec5d79672c1a.zip
Merge remote-tracking branch 'cweb/master'
Diffstat (limited to 'extlib/leaflet/src/layer/FeatureGroup.js')
-rw-r--r--extlib/leaflet/src/layer/FeatureGroup.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/extlib/leaflet/src/layer/FeatureGroup.js b/extlib/leaflet/src/layer/FeatureGroup.js
new file mode 100644
index 00000000..6e45d84c
--- /dev/null
+++ b/extlib/leaflet/src/layer/FeatureGroup.js
@@ -0,0 +1,40 @@
+/*
+ * L.FeatureGroup extends L.LayerGroup by introducing mouse events and bindPopup method shared between a group of layers.
+ */
+
+L.FeatureGroup = L.LayerGroup.extend({
+ includes: L.Mixin.Events,
+
+ addLayer: function(layer) {
+ this._initEvents(layer);
+ L.LayerGroup.prototype.addLayer.call(this, layer);
+
+ if (this._popupContent && layer.bindPopup) {
+ layer.bindPopup(this._popupContent);
+ }
+ },
+
+ bindPopup: function(content) {
+ this._popupContent = content;
+
+ for (var i in this._layers) {
+ if (this._layers.hasOwnProperty(i) && this._layers[i].bindPopup) {
+ this._layers[i].bindPopup(content);
+ }
+ }
+ },
+
+ _events: ['click', 'dblclick', 'mouseover', 'mouseout'],
+
+ _initEvents: function(layer) {
+ for (var i = 0, len = this._events.length; i < len; i++) {
+ layer.on(this._events[i], this._propagateEvent, this);
+ }
+ },
+
+ _propagateEvent: function(e) {
+ e.layer = e.target;
+ e.target = this;
+ this.fire(e.type, e);
+ }
+}); \ No newline at end of file