From 334eec7e9ce359a769f328147fc86bd069d01086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 27 Jun 2018 14:42:01 +0200 Subject: [PATCH] maps: change gps button behaviour not to watch position continuously (#24810) --- combo/apps/maps/static/js/leaflet-gps.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/combo/apps/maps/static/js/leaflet-gps.js b/combo/apps/maps/static/js/leaflet-gps.js index e14c6bf..eea825f 100644 --- a/combo/apps/maps/static/js/leaflet-gps.js +++ b/combo/apps/maps/static/js/leaflet-gps.js @@ -49,9 +49,9 @@ 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.style.fontFamily = 'FontAwesome'; @@ -67,7 +67,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 +75,8 @@ L.Control.Gps = L.Control.extend({ }, _askGps: function() { + this._firstMoved = false; + this._container.classList.add('pending'); this.activate(); }, @@ -91,13 +93,13 @@ L.Control.Gps = L.Control.extend({ this.addLayer(); this._map.locate({ enableHighAccuracy: true, - watch: true, setView: false, maxZoom: null }); }, deactivate: function() { + this._container.classList.remove('pending'); this._isActive = false; this._firstMoved = false; this._map.stopLocate(); @@ -106,6 +108,7 @@ L.Control.Gps = L.Control.extend({ }, _drawGps: function(e) { + this._container.classList.remove('pending'); this._currentLocation = e.latlng; this._gpsMarker.setLatLng(this._currentLocation); -- 2.17.1