1 L.Control.Share = L.Control.extend({
10 onAdd: function (map) {
11 var className = 'leaflet-control-locate',
12 classNames = className + ' leaflet-control-zoom leaflet-bar leaflet-control',
13 container = L.DomUtil.create('div', classNames);
15 var link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single', container);
17 link.title = this.options.title;
19 this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container);
22 .on(this._uiPane, 'click', L.DomEvent.stopPropagation)
23 .on(this._uiPane, 'click', L.DomEvent.preventDefault)
24 .on(this._uiPane, 'dblclick', L.DomEvent.preventDefault);
26 var h2 = L.DomUtil.create('h2', '', this._uiPane);
27 h2.innerHTML = I18n.t('javascripts.share.title');
29 this._linkInput = L.DomUtil.create('input', '', this._uiPane);
32 .on(link, 'click', L.DomEvent.stopPropagation)
33 .on(link, 'click', L.DomEvent.preventDefault)
34 .on(link, 'click', this._toggle, this)
35 .on(link, 'dblclick', L.DomEvent.stopPropagation);
37 map.on('moveend layeradd layerremove', this._update, this);
42 _update: function (e) {
43 var center = map.getCenter().wrap();
44 var layers = getMapLayers();
45 this._linkInput.value = this.options.getUrl(map);
49 var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
51 if ($(this._uiPane).is(':visible')) {
52 $(this._uiPane).hide();
53 controlContainer.css({paddingRight: '0'});
55 $(this._uiPane).show();
56 controlContainer.css({paddingRight: '200px'});
61 L.control.share = function(options) {
62 return new L.Control.Share(options);