Sha256: d2cce13326cf8cd0d4dd36ce728a90fe0da23e9f4c085a8357366bc262d0d231

Contents?: true

Size: 1.35 KB

Versions: 9

Compression:

Stored size: 1.35 KB

Contents

// Add in an option to icon that is used to set where the label anchor is
L.Icon.Default.mergeOptions({
	labelAnchor: new L.Point(9, -20)
});

// Have to do this since Leaflet is loaded before this plugin and initializes
// L.Marker.options.icon therefore missing our mixin above.
L.Marker.mergeOptions({
	icon: new L.Icon.Default()
});

L.Marker.include(L.BaseMarkerMethods);
L.Marker.include({
	_originalUpdateZIndex: L.Marker.prototype._updateZIndex,

	_updateZIndex: function (offset) {
		var zIndex = this._zIndex + offset;

		this._originalUpdateZIndex(offset);

		if (this.label) {
			this.label.updateZIndex(zIndex);
		}
	},

	_originalSetOpacity: L.Marker.prototype.setOpacity,

	setOpacity: function (opacity, labelHasSemiTransparency) {
		this.options.labelHasSemiTransparency = labelHasSemiTransparency;

		this._originalSetOpacity(opacity);
	},

	_originalUpdateOpacity: L.Marker.prototype._updateOpacity,

	_updateOpacity: function () {
		var absoluteOpacity = this.options.opacity === 0 ? 0 : 1;

		this._originalUpdateOpacity();

		if (this.label) {
			this.label.setOpacity(this.options.labelHasSemiTransparency ? this.options.opacity : absoluteOpacity);
		}
	},

	_originalSetLatLng: L.Marker.prototype.setLatLng,

	setLatLng: function (latlng) {
		if (this.label && !this._labelNoHide) {
			this.hideLabel();
		}

		return this._originalSetLatLng(latlng);
	}
});

Version data entries

9 entries across 9 versions & 1 rubygems

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