aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/src/layer/FeatureGroup.js
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2012-01-10 01:54:37 +0100
committerJoar Wandborg <git@wandborg.com>2012-01-25 23:42:04 +0100
commitc5ba5b0456a711d157e317f220e9c739226e7f50 (patch)
tree2800568ac8e484649a978e0fe7e682a8bcfe20d4 /extlib/leaflet/src/layer/FeatureGroup.js
parentc47a03b909ecd97cab5b144d0cab007b62b92a90 (diff)
downloadmediagoblin-c5ba5b0456a711d157e317f220e9c739226e7f50.tar.lz
mediagoblin-c5ba5b0456a711d157e317f220e9c739226e7f50.tar.xz
mediagoblin-c5ba5b0456a711d157e317f220e9c739226e7f50.zip
Installed leaflet in extlib
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