1 //= require templates/map/share
3 L.Control.Share = L.Control.extend({
12 onAdd: function (map) {
13 var className = 'leaflet-control-locate',
14 classNames = className + ' leaflet-control-zoom leaflet-bar leaflet-control',
15 container = L.DomUtil.create('div', classNames);
17 var link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single', container);
19 link.title = this.options.title;
21 this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container);
22 this._linkInput = L.DomUtil.create('input', '', this._uiPane);
25 .on(link, 'click', L.DomEvent.stopPropagation)
26 .on(link, 'click', L.DomEvent.preventDefault)
27 .on(link, 'click', this._toggle, this)
28 .on(link, 'dblclick', L.DomEvent.stopPropagation);
30 map.on('moveend layeradd layerremove', this._update, this);
35 _update: function (e) {
36 var center = map.getCenter().wrap();
37 var layers = getMapLayers();
38 this._linkInput.value = this.options.getUrl(map);
42 var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
44 if ($(this._uiPane).is(':visible')) {
45 $(this._uiPane).hide();
46 controlContainer.css({paddingRight: '0'});
48 $(this._uiPane).show();
49 controlContainer.css({paddingRight: '200px'});
54 L.control.share = function(options) {
55 return new L.Control.Share(options);