commit d3e561f79fa5c2ae570e55b8f5056d435f644878
parent 0fad88b06d3c42c0c8c88428b2a12d278a9b96ae
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Fri, 3 Nov 2017 12:43:34 +0300
[coordinates control] removed Copy item from context menu on control; added showing context menu for left click on map
Diffstat:
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/src/lib/leaflet.control.coordinates/index.js b/src/lib/leaflet.control.coordinates/index.js
@@ -52,8 +52,6 @@ L.Control.Coordinates = L.Control.extend({
}, this
);
this.menu = new Contextmenu([
- {text: 'Click map to copy coordinates to clipboard', callback: this.prepareForClickOnMap.bind(this)},
- '-',
{text: '±ddd.ddddd', callback: this.onMenuSelect.bind(this, 'd')},
{text: 'ddd.ddddd°', callback: this.onMenuSelect.bind(this, 'D')},
{text: 'ddd°mm.mmm\'', callback: this.onMenuSelect.bind(this, 'DM')},
@@ -149,16 +147,16 @@ L.Control.Coordinates = L.Control.extend({
L.DomUtil.addClass(this._container, 'expanded');
L.DomUtil.addClass(this._map._container, 'coordinates-control-active');
this._map.on('mousemove', this.onMouseMove, this);
- this._map.on('contextmenu', this.onMapRightClick, this);
+ this._map.on('contextmenu click', this.onMapClick, this);
} else {
L.DomUtil.removeClass(this._container, 'expanded');
L.DomUtil.removeClass(this._map._container, 'coordinates-control-active');
- this._map.off('contextmenu', this.onMapRightClick, this);
+ this._map.off('contextmenu click', this.onMapClick, this);
this._map.off('mousemove', this.onMouseMove, this);
}
},
- onMapRightClick: function(e) {
+ onMapClick: function(e) {
L.DomEvent.stop(e);
const items = [{text: '<b>Copy coordinates to clipboard</b>', header: true}, '-'];
@@ -195,17 +193,6 @@ L.Control.Coordinates = L.Control.extend({
this.menu.show(e);
},
- onMapClick: function(e) {
- var s = this.formatCoodinate(e.latlng.lat, true) + ' ' + this.formatCoodinate(e.latlng.lng, false);
- s = s.replace(/°/g, '°');
- copyToClipboard(s, e.originalEvent);
- },
-
- prepareForClickOnMap: function() {
- this._map.once('click', this.onMapClick, this);
- }
-
-
// TODO: onRemove