Sha256: 3373ba6b75e21d76e1d29b829a6263caa2aaf22d110287526e6ef8fc1b938c67
Contents?: true
Size: 1.72 KB
Versions: 9
Compression:
Stored size: 1.72 KB
Contents
L.Tooltip = L.Class.extend({ initialize: function (map) { this._map = map; this._popupPane = map._panes.popupPane; this._container = map.options.drawControlTooltips ? L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null; this._singleLineLabel = false; }, dispose: function () { if (this._container) { this._popupPane.removeChild(this._container); this._container = null; } }, updateContent: function (labelText) { if (!this._container) { return this; } labelText.subtext = labelText.subtext || ''; // update the vertical position (only if changed) if (labelText.subtext.length === 0 && !this._singleLineLabel) { L.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single'); this._singleLineLabel = true; } else if (labelText.subtext.length > 0 && this._singleLineLabel) { L.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single'); this._singleLineLabel = false; } this._container.innerHTML = (labelText.subtext.length > 0 ? '<span class="leaflet-draw-tooltip-subtext">' + labelText.subtext + '</span>' + '<br />' : '') + '<span>' + labelText.text + '</span>'; return this; }, updatePosition: function (latlng) { var pos = this._map.latLngToLayerPoint(latlng), tooltipContainer = this._container; if (this._container) { tooltipContainer.style.visibility = 'inherit'; L.DomUtil.setPosition(tooltipContainer, pos); } return this; }, showAsError: function () { if (this._container) { L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip'); } return this; }, removeError: function () { if (this._container) { L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip'); } return this; } });
Version data entries
9 entries across 9 versions & 1 rubygems