aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/src/layer/vector/Path.Popup.js
blob: b82a4920f15372d88103e681702e881ab7d06234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * Popup extension to L.Path (polylines, polygons, circles), adding bindPopup method. 
 */

L.Path.include({
	bindPopup: function(content, options) {
		if (!this._popup || this._popup.options !== options) {
			this._popup = new L.Popup(options);
		}
		this._popup.setContent(content);
		
		if (!this._openPopupAdded) {
			this.on('click', this._openPopup, this);
			this._openPopupAdded = true;
		}
		
		return this;
	},
	
	_openPopup: function(e) {
		this._popup.setLatLng(e.latlng);
		this._map.openPopup(this._popup);
	}	
});