Issue
I'm using Mapbox for Android Java and need to calculate the distance between a drawn line defined by start and endpoint to the users current location.
Any idea on how to implement that with mapbox?
Solution
You have some Turf.js (a geospatial analysis library) methods ported to Android: https://docs.mapbox.com/android/java/guides/turf/
- Use
TurfMisc.nearestPointOnLine()
with the line and the user location as an input - Then use
TurfMeasurement.distance()
between the two points
Answered By - Etherlind
Answer Checked By - Mildred Charles (JavaFixing Admin)