From 56af0da45e86792f7a75442fac6a55afdadb3055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 13 Sep 2018 09:58:28 +0200 Subject: [PATCH 1/2] maps: sync leaflet-gps with combo (#26375) --- wcs/qommon/static/js/leaflet-gps.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/wcs/qommon/static/js/leaflet-gps.js b/wcs/qommon/static/js/leaflet-gps.js index e14c6bf6f..1414239d3 100644 --- a/wcs/qommon/static/js/leaflet-gps.js +++ b/wcs/qommon/static/js/leaflet-gps.js @@ -34,7 +34,8 @@ L.Control.Gps = L.Control.extend({ fillColor: '#f23', fillOpacity: 1 }, - position: 'topleft' + position: 'topleft', + tooltipTitle: 'Display my position' }, initialize: function(options) { @@ -49,13 +50,13 @@ L.Control.Gps = L.Control.extend({ onAdd: function (map) { this._map = map; - var container = L.DomUtil.create('div', 'leaflet-control-gps leaflet-bar'); + this._container = L.DomUtil.create('div', 'leaflet-control-gps leaflet-bar'); - this._button = L.DomUtil.create('a', 'gps-button', container); + this._button = L.DomUtil.create('a', 'gps-button', this._container); this._button.href = '#'; this._button.text = '\uf192'; + this._button.title = this.options.tooltipTitle; this._button.style.fontFamily = 'FontAwesome'; - this._button.style.borderRadius = '4px'; L.DomEvent .on(this._button, 'click', L.DomEvent.stop, this) .on(this._button, 'click', this._askGps, this); @@ -67,7 +68,7 @@ L.Control.Gps = L.Control.extend({ .on('locationfound', this._drawGps, this) .on('locationerror', this._errorGps, this); - return container; + return this._container; }, onRemove: function(map) { @@ -75,6 +76,8 @@ L.Control.Gps = L.Control.extend({ }, _askGps: function() { + this._firstMoved = false; + this._container.classList.add('pending'); this.activate(); }, @@ -98,6 +101,7 @@ L.Control.Gps = L.Control.extend({ }, deactivate: function() { + this._container.classList.remove('pending'); this._isActive = false; this._firstMoved = false; this._map.stopLocate(); @@ -106,12 +110,15 @@ L.Control.Gps = L.Control.extend({ }, _drawGps: function(e) { + this._container.classList.remove('pending'); this._currentLocation = e.latlng; this._gpsMarker.setLatLng(this._currentLocation); - if(this._isActive && !this._firstMoved) + if(this._isActive && !this._firstMoved) { this._moveTo(this._currentLocation); + this._map.stopLocate(); + } if (this._isActive) { this.fire('gps:located', {latlng: this._currentLocation, marker: this._gpsMarker}); -- 2.19.0