Sha256: 7c6a8de0c01a9c830fa6a05de49f84d34a0d0d1775a7694ba33931c7754955c8

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

L.Path.include({
	bindLabel: function (content, options) {
		if (!this.label || this.label.options !== options) {
			this.label = new L.Label(options, this);
		}

		this.label.setContent(content);

		if (!this._showLabelAdded) {
			this
				.on('mouseover', this._showLabel, this)
				.on('mousemove', this._moveLabel, this)
				.on('mouseout remove', this._hideLabel, this);

			if (L.Browser.touch) {
				this.on('click', this._showLabel, this);
			}
			this._showLabelAdded = true;
		}

		return this;
	},

	unbindLabel: function () {
		if (this.label) {
			this._hideLabel();
			this.label = null;
			this._showLabelAdded = false;
			this
				.off('mouseover', this._showLabel, this)
				.off('mousemove', this._moveLabel, this)
				.off('mouseout remove', this._hideLabel, this);
		}
		return this;
	},

	updateLabelContent: function (content) {
		if (this.label) {
			this.label.setContent(content);
		}
	},

	_showLabel: function (e) {
		this.label.setLatLng(e.latlng);
		this._map.showLabel(this.label);
	},

	_moveLabel: function (e) {
		this.label.setLatLng(e.latlng);
	},

	_hideLabel: function () {
		this.label.close();
	}
});

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
leaflet-js-0.7.9 vendor/assets/Leaflet.label/src/Path.Label.js
leaflet-js-0.7.8 vendor/assets/Leaflet.label/src/Path.Label.js
leaflet-js-0.7.7 vendor/assets/Leaflet.label/src/Path.Label.js
leaflet-js-0.8.dev2 lib/leaflet.label/src/Path.Label.js
leaflet-js-0.7.0.4 lib/leaflet.label/src/Path.Label.js
leaflet-js-0.7.0.3 lib/leaflet.label/src/Path.Label.js
leaflet-js-0.7.0.2 lib/leaflet.label/src/Path.Label.js
leaflet-js-0.7.0.1 lib/leaflet.label/src/Path.Label.js
leaflet-js-0.7.0 lib/leaflet.label/src/Path.Label.js