Junnel
Junnel

Reputation: 107

Q: Cordova Phonegap Geolocation getting the right speed?

I made an app that tracks users location now i need to get the speed also. I manage to put position.coords.speed but it always shows 0. I noticed that the gps tracker/icon is not actively tracking. What is the best practice on tracking the speed of the user? I am using the plugin cordova-plugin-geolocation

Upvotes: 2

Views: 538

Answers (1)

DaveAlden
DaveAlden

Reputation: 30356

Have you requested high accuracy in the options when requesting location? For example:

navigator.geolocation.watchPosition(onSuccess, onError, {
  enableHighAccuracy: true,
  timeout: 30000,
  maxAge: 0
});

If position.coords.speed is zero and the gps/location icon is not shown in the taskbar, this might be the cause.

Upvotes: 1

Related Questions