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() }])
})