aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/src/layer/marker/Marker.Popup.js
blob: 4c5cad0479a99503140a7b2b5723fa0eaf67526d (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
25
26
27
28
/*
 * Popup extension to L.Marker, adding openPopup & bindPopup methods. 
 */

L.Marker.include({
	openPopup: function() {
		this._popup.setLatLng(this._latlng);
		this._map.openPopup(this._popup);
		
		return this;
	},
	
	closePopup: function() {
		if (this._popup) {
			this._popup._close();
		}
	},
	
	bindPopup: function(content, options) {
		options = L.Util.extend({offset: this.options.icon.popupAnchor}, options);
		
		this._popup = new L.Popup(options);
		this._popup.setContent(content);
		this.on('click', this.openPopup, this);
		
		return this;
	}
});