1 L.Control.Share = L.Control.extend({
10 onAdd: function (map) {
11 var className = 'control-share',
12 container = L.DomUtil.create('div', className);
14 var link = L.DomUtil.create('a', 'control-button', container);
15 link.innerHTML = "<span class='icon share'></span>";
17 link.title = this.options.title;
19 this._uiPane = this.options.uiPane;
23 var h2 = L.DomUtil.create('h2', '', this._uiPane);
24 h2.innerHTML = I18n.t('javascripts.share.title');
26 this._linkInput = L.DomUtil.create('input', '', this._uiPane);
29 .on(link, 'click', L.DomEvent.stopPropagation)
30 .on(link, 'click', L.DomEvent.preventDefault)
31 .on(link, 'click', this._toggle, this)
32 .on(link, 'dblclick', L.DomEvent.stopPropagation);
34 map.on('moveend layeradd layerremove', this._update, this);
39 _update: function (e) {
40 var center = this._map.getCenter().wrap();
41 var layers = getMapLayers(this._map);
42 this._linkInput.value = this.options.getUrl(this._map);
46 var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
48 if ($(this._uiPane).is(':visible')) {
49 $(this._uiPane).hide();
50 controlContainer.css({paddingRight: '0'});
52 $(this._uiPane).show();
53 controlContainer.css({paddingRight: '200px'});
58 L.control.share = function(options) {
59 return new L.Control.Share(options);