Track distance travelled using GPS
I have an app (Android and iOS) that shows the User their current location on a map (using Mapbox) with location-based markers. When they go to these locations physically, they unlock content.
This all works great but now I want to add a new functionality: Track the distance they have walked.
As they can start at any marker and visit them in any order, I don't want to calculate 'as the bird flies' but rather, the exact route they took; as this is the real world, they wouldn't necessarily walk in a straight line.
How would I go about tracking how far they have walked? I'm thinking I could use the GPS in some way. Ideally I would also like to update it regularly so they can see their progress whenever they want.
Answer by elenzil · Jun 17, 2021 at 06:24 PM
wouldn't you just use MapBox's Directions API and add up the route distances between all consecutive marker-visits ? ie, this assumes they've followed reasonably short paths on known walkways, etc, but it avoids your app having to constantly monitor GPS.
Thanks for replying. I will have a look into the directions api. They are following short paths as the markers will be in a small area. However, a lot of my routes are in places such as parks where people won't necessarily use known pathways all the time. I'm already using GPS to track the current location of the user, this updates regularly, so I'm guessing I could just calculate the distance each time the users location updates, although that might be quite heavy
If you're already tracking GPS on regular intervals, just add 'em up. What part do you think will be heavy ?
Your answer
Follow this Question
Related Questions
Trying to Build GPS Tracking Based App, Help 0 Answers
Way to detect movement on mobile devices 0 Answers
GPS coordinates not changing at all! 0 Answers
Input.location GPS issue 1 Answer
Calculate the arc distance between 2 points on a sphere 3 Answers