Installed leaflet in extlib
[mediagoblin.git] / extlib / leaflet / src / layer / FeatureGroup.js
1 /*
2 * L.FeatureGroup extends L.LayerGroup by introducing mouse events and bindPopup method shared between a group of layers.
3 */
4
5 L.FeatureGroup = L.LayerGroup.extend({
6 includes: L.Mixin.Events,
7
8 addLayer: function(layer) {
9 this._initEvents(layer);
10 L.LayerGroup.prototype.addLayer.call(this, layer);
11
12 if (this._popupContent && layer.bindPopup) {
13 layer.bindPopup(this._popupContent);
14 }
15 },
16
17 bindPopup: function(content) {
18 this._popupContent = content;
19
20 for (var i in this._layers) {
21 if (this._layers.hasOwnProperty(i) && this._layers[i].bindPopup) {
22 this._layers[i].bindPopup(content);
23 }
24 }
25 },
26
27 _events: ['click', 'dblclick', 'mouseover', 'mouseout'],
28
29 _initEvents: function(layer) {
30 for (var i = 0, len = this._events.length; i < len; i++) {
31 layer.on(this._events[i], this._propagateEvent, this);
32 }
33 },
34
35 _propagateEvent: function(e) {
36 e.layer = e.target;
37 e.target = this;
38 this.fire(e.type, e);
39 }
40 });