location tracking centering screen

This commit is contained in:
Ward 2021-07-13 14:57:51 +02:00
parent ca1871262e
commit 4c4b0356c1

View file

@ -72,23 +72,26 @@ export default class GeoLocationHandler extends VariableUiElement {
"geolocation-permissions" "geolocation-permissions"
); );
const isActive = new UIEventSource<boolean>(false); const isActive = new UIEventSource<boolean>(false);
const isLocked = new UIEventSource<boolean>(false);
super( super(
hasLocation.map( hasLocation.map(
(hasLocation) => { (hasLocationData) => {
if (hasLocation) { if (isLocked.data) {
return Svg.up_ui();
} else if (hasLocationData) {
return Svg.crosshair_blue_ui(); return Svg.crosshair_blue_ui();
} } else if (isActive.data) {
if (isActive.data) {
return Svg.crosshair_blue_center_ui(); return Svg.crosshair_blue_center_ui();
} } else {
return Svg.crosshair_ui(); return Svg.crosshair_ui();
}
}, },
[isActive] [isActive, isLocked]
) )
); );
this._isActive = isActive; this._isActive = isActive;
this._isLocked = new UIEventSource<boolean>(false); this._isLocked = isLocked;
this._permission = new UIEventSource<string>(""); this._permission = new UIEventSource<string>("");
this._previousLocationGrant = previousLocationGrant; this._previousLocationGrant = previousLocationGrant;
this._currentGPSLocation = currentGPSLocation; this._currentGPSLocation = currentGPSLocation;
@ -110,7 +113,12 @@ export default class GeoLocationHandler extends VariableUiElement {
self.SetClass(pointerClass); self.SetClass(pointerClass);
}); });
this.onClick(() => self.init(true)); this.onClick(() => {
self.init(true);
if (self._isActive.data) {
self._isLocked.setData(!self._isLocked.data);
}
});
this.init(false); this.init(false);
this._currentGPSLocation.addCallback((location) => { this._currentGPSLocation.addCallback((location) => {
@ -139,7 +147,6 @@ export default class GeoLocationHandler extends VariableUiElement {
}); });
const map = self._leafletMap.data; const map = self._leafletMap.data;
console.log("check for map", map);
const newMarker = L.marker(location.latlng, { icon: icon }); const newMarker = L.marker(location.latlng, { icon: icon });
newMarker.addTo(map); newMarker.addTo(map);