Sha256: 8df40c682639e090d2fba0b9171525530ba2f8c91cb96328df8148560bd4b4a4
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
/* * Popup extension to L.Marker, adding popup-related methods. */ L.Marker.include({ openPopup: function () { if (this._popup && this._map && !this._map.hasLayer(this._popup)) { this._popup.setLatLng(this._latlng); this._map.openPopup(this._popup); } return this; }, closePopup: function () { if (this._popup) { this._popup._close(); } return this; }, togglePopup: function () { if (this._popup) { if (this._popup._isOpen) { this.closePopup(); } else { this.openPopup(); } } return this; }, bindPopup: function (content, options) { var anchor = L.point(this.options.icon.options.popupAnchor || [0, 0]); anchor = anchor.add(L.Popup.prototype.options.offset); if (options && options.offset) { anchor = anchor.add(options.offset); } options = L.extend({offset: anchor}, options); if (!this._popupHandlersAdded) { this .on('click', this.togglePopup, this) .on('remove', this.closePopup, this) .on('move', this._movePopup, this); this._popupHandlersAdded = true; } if (content instanceof L.Popup) { L.setOptions(content, options); this._popup = content; content._source = this; } else { this._popup = new L.Popup(options, this) .setContent(content); } return this; }, setPopupContent: function (content) { if (this._popup) { this._popup.setContent(content); } return this; }, unbindPopup: function () { if (this._popup) { this._popup = null; this .off('click', this.togglePopup, this) .off('remove', this.closePopup, this) .off('move', this._movePopup, this); this._popupHandlersAdded = false; } return this; }, getPopup: function () { return this._popup; }, _movePopup: function (e) { this._popup.setLatLng(e.latlng); } });
Version data entries
3 entries across 3 versions & 1 rubygems