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;
21 var h2 = L.DomUtil.create('h2', '', this._uiPane);
22 h2.innerHTML = I18n.t('javascripts.share.title');
24 this._linkInput = L.DomUtil.create('input', '', this._uiPane);
27 .on(link, 'click', L.DomEvent.stopPropagation)
28 .on(link, 'click', L.DomEvent.preventDefault)
29 .on(link, 'click', this._toggle, this)
30 .on(link, 'dblclick', L.DomEvent.stopPropagation);
32 map.on('moveend layeradd layerremove', this._update, this);
37 _update: function (e) {
38 var center = map.getCenter().wrap();
39 var layers = getMapLayers();
40 this._linkInput.value = this.options.getUrl(map);
44 var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
46 if ($(this._uiPane).is(':visible')) {
47 $(this._uiPane).hide();
48 controlContainer.css({paddingRight: '0'});
50 $(this._uiPane).show();
51 controlContainer.css({paddingRight: '200px'});
56 L.control.share = function(options) {
57 return new L.Control.Share(options);