Projet

Général

Profil

0001-maps-change-gps-button-behaviour-not-to-watch-positi.patch

Frédéric Péters, 27 juin 2018 15:05

Télécharger (2,25 ko)

Voir les différences:

Subject: [PATCH] maps: change gps button behaviour not to watch position
 continuously (#24810)

 combo/apps/maps/static/js/leaflet-gps.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
combo/apps/maps/static/js/leaflet-gps.js
49 49
	onAdd: function (map) {
50 50
		this._map = map;
51 51

  
52
		var container = L.DomUtil.create('div', 'leaflet-control-gps leaflet-bar');
52
		this._container = L.DomUtil.create('div', 'leaflet-control-gps leaflet-bar');
53 53

  
54
		this._button = L.DomUtil.create('a', 'gps-button', container);
54
		this._button = L.DomUtil.create('a', 'gps-button', this._container);
55 55
		this._button.href = '#';
56 56
		this._button.text = '\uf192';
57 57
		this._button.style.fontFamily = 'FontAwesome';
......
67 67
			.on('locationfound', this._drawGps, this)
68 68
			.on('locationerror', this._errorGps, this);
69 69

  
70
		return container;
70
		return this._container;
71 71
	},
72 72

  
73 73
	onRemove: function(map) {
......
75 75
	},
76 76

  
77 77
	_askGps: function() {
78
		this._firstMoved = false;
79
		this._container.classList.add('pending');
78 80
		this.activate();
79 81
	},
80 82

  
......
98 100
	},
99 101

  
100 102
	deactivate: function() {
103
		this._container.classList.remove('pending');
101 104
		this._isActive = false;
102 105
		this._firstMoved = false;
103 106
		this._map.stopLocate();
......
106 109
	},
107 110

  
108 111
	_drawGps: function(e) {
112
		this._container.classList.remove('pending');
109 113
		this._currentLocation = e.latlng;
110 114

  
111 115
		this._gpsMarker.setLatLng(this._currentLocation);
112 116

  
113
		if(this._isActive && !this._firstMoved)
117
		if(this._isActive && !this._firstMoved) {
114 118
			this._moveTo(this._currentLocation);
119
			this._map.stopLocate();
120
		}
115 121

  
116 122
                if (this._isActive) {
117 123
			this.fire('gps:located', {latlng: this._currentLocation, marker: this._gpsMarker});
118
-