diff --git a/Logic/Actors/GeoLocationHandler.ts b/Logic/Actors/GeoLocationHandler.ts index a5f51959e..b458af29f 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 9d11abeab..edf09cfb8 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 +}