Sha256: 4a9ddcb06a70fb7e1299e9725de48eeb5dd93fb16f5076fe4d65f5ac0d080cb2

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

L.Control.Attribution = L.Class.extend({
	initialize: function (prefix) {
		this._prefix = prefix || 'Powered by <a href="http://leaflet.cloudmade.com">Leaflet</a>';
		this._attributions = {};
	},
	
	onAdd: function (map) {
		this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
		L.DomEvent.disableClickPropagation(this._container);
		this._map = map;
		this._update();
	},

	getPosition: function () {
		return L.Control.Position.BOTTOM_RIGHT;
	},

	getContainer: function () {
		return this._container;
	},

	setPrefix: function (prefix) {
		this._prefix = prefix;
		this._update();
	},

	addAttribution: function (text) {
		if (!text) {
			return;
		}
		this._attributions[text] = true;
		this._update();
	},

	removeAttribution: function (text) {
		if (!text) {
			return;
		}
		delete this._attributions[text];
		this._update();
	},

	_update: function () {
		if (!this._map) {
			return;
		}

		var attribs = [];

		for (var i in this._attributions) {
			if (this._attributions.hasOwnProperty(i)) {
				attribs.push(i);
			}
		}

		var prefixAndAttribs = [];
		if (this._prefix) {
			prefixAndAttribs.push(this._prefix);
		}
		if (attribs.length) {
			prefixAndAttribs.push(attribs.join(', '));
		}

		this._container.innerHTML = prefixAndAttribs.join(' &mdash; ');
	}
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
leaflet-ruby-0.3.beta4 lib/leaflet/src/control/Control.Attribution.js
leaflet-ruby-0.3.beta3 lib/leaflet/src/control/Control.Attribution.js
leaflet-ruby-0.3.beta1 lib/leaflet/src/control/Control.Attribution.js