Fix: gps-icon should turn into an arrow again

This commit is contained in:
Pieter Vander Vennet 2023-03-22 16:25:24 +01:00
parent b99588b4ba
commit ef93ad126f
2 changed files with 11 additions and 2 deletions

View file

@ -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: <GeoLocationPointProperties>{
@ -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() }])
})

View file

@ -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 @@
]
}
]
}
}