Expo Location Module doesn't return a speed

I’ve written a React Native / Expo app that uses the Expo Location module.

In it, it uses the Location.getCurrentPositionAsync to get a JSON dictionary with position, speed and heading.

Yet, whatever I do, the “speed” portion seems to come in as “zero”. This is true on both Android and iOS. I’m getting the data like this:

let location = await Location.getCurrentPositionAsync({accuracy: 6});

And I get an object like this:

Object {
  "coords": Object {
    "accuracy": 13.522000312805176,
    "altitude": 5,
    "heading": 0,
    "latitude": 37.4219983,
    "longitude": -122.084,
    "speed": 0,
  "mocked": false,
  "timestamp": 1550650746000,

Does the Expo Location module simply not collect GPS speeds? Or am I calling it wrong?

Thanks Robert

1 Like

Hey @rcs1000!

After building a quick snack, I am able to get an appropriate return value for speed (-1 since the device isn’t moving, but that is expected).

Please link a snack that reproduces your issue, that way I can help :slight_smile:

Yes, I get -1 on iOS. But it’s always -1. If I get in my car and drive around, it stays at -1

If I’m on Android and drive around it stays at 0.

I’ve set it up so that every second I call

let location = await Location.getCurrentPositionAsync({accuracy: 6});

And then I dump the location object to the logs. The latititude and the longitude change, but the speed is always zero.

To test whether it’s a problem with my device(s). I created a simple Kivy app that dumped the .speed portion of a GPS read to the logs. And that worked fine.

Is it possible to install an older version of Expo (31?) before the Location module changed to see if there is something there that caused the problem?


I’m asking our Locations API expert now, I’ll get back to you about it as soon as I can :slight_smile:

To answer your question, yes it’s possible to downgrade to an older SDK, although it is not suggested. You can read about that here

1 Like

Thank you very much.

So Expo is simply copying the speed value from the iOS location object, you can take a look here for their docs.

By just asking for one current location, not sure if it’s possible to obtain a value for speed

This is also explained here -> https://stackoverflow.com/questions/30098202/cllocationmanager-always-returning-speed-1/30107728#30107728

1 Like

And on Android?

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.