Search code examples
androidcordovageolocationgpsphonegap

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


Solution

  • 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.