maps: change gps button behaviour not to watch position continuously (#24810)
This commit is contained in:
parent
7ff1299e2f
commit
743cadaf89
|
@ -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();
|
||||
},
|
||||
|
||||
|
@ -98,6 +100,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 +109,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});
|
||||
|
|
Loading…
Reference in New Issue