From ef93ad126f5c6b973fb2f66c368522ebdee07543 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 22 Mar 2023 16:25:24 +0100 Subject: [PATCH] Fix: gps-icon should turn into an arrow again --- Logic/Actors/GeoLocationHandler.ts | 9 +++++++++ assets/layers/gps_location/gps_location.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Logic/Actors/GeoLocationHandler.ts b/Logic/Actors/GeoLocationHandler.ts index a5f51959e1..b458af29fe 100644 --- a/Logic/Actors/GeoLocationHandler.ts +++ b/Logic/Actors/GeoLocationHandler.ts @@ -130,10 +130,14 @@ export default class GeoLocationHandler { private CopyGeolocationIntoMapstate() { const state = this._state + // For some weird reason, the 'Object.keys' method doesn't work for the 'location: GeolocationCoordinates'-object and will thus not copy all the properties when using {...location} + // As such, they are copied here + const keysToCopy = ["speed", "accuracy", "altitude", "altitudeAccuracy", "heading"] this.geolocationState.currentGPSLocation.addCallbackAndRun((location) => { if (location === undefined) { return } + const feature = { type: "Feature", properties: { @@ -147,6 +151,11 @@ export default class GeoLocationHandler { coordinates: [location.longitude, location.latitude], }, } + for (const key of keysToCopy) { + if (location[key] !== null) { + feature.properties[key] = location[key] + } + } state.currentUserLocation?.features?.setData([{ feature, freshness: new Date() }]) }) diff --git a/assets/layers/gps_location/gps_location.json b/assets/layers/gps_location/gps_location.json index 9d11abeab5..edf09cfb83 100644 --- a/assets/layers/gps_location/gps_location.json +++ b/assets/layers/gps_location/gps_location.json @@ -1,6 +1,6 @@ { "id": "gps_location", - "description": "Meta layer showing the current location of the user. Add this to your theme and override the icon to change the appearance of the current location. The object will always have `id=gps` and will have _all_ the properties included in the [`Coordinates`-object](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates) returned by the browser.", + "description": "Meta layer showing the current location of the user. Add this to your theme and override the icon to change the appearance of the current location. The object will always have `id=gps` and will have _all_ the properties included in the [`Coordinates`-object](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates) (except latitude and longitude) returned by the browser, such as `speed`, `altitude`, `heading`, ....", "minzoom": 0, "source": { "osmTags": "id=gps", @@ -38,4 +38,4 @@ ] } ] -} \ No newline at end of file +}