Search code examples
javascriptwebgeolocationgps

How accurate and reliable is GeolocationCoordinates.speed API?


I was wondering how accurate and reliable is the property speed of a single sample of GeolocationCoordinates API.

I want to take few samples of the current speed of an object (with GPS) and I am not sure if I should calculate the velocity myself (by the distance traveled between two time samples using altitude, longitude and altitude), or just use the property speed of a simple GeolocationCoordinates sample.

How does the speed property is being measured? Which approach should I take?


Solution

  • The GeolocationCoordinates.speed read-only property is a double representing the velocity of the device in meters per second.

    source, also this might help

    So I guess you don't have to calculate it manually.

    TIP: For better accuracy, make sure the device is not in battery save mode, as it affects the result a lot.