问题
I have 3 Locations, Location A,B and C. Now let's assume in a Polyline Location A comes first Location B second and Location C third. Just assume that my current location is Location B. Now I can clearly see that I have traveled or covered Location A and my upcoming Location is Location C on a polyline, but how can I know these things programmatically that I have covered these much of points of the Polyline.
I have a list of Latitude and Longitude which forms a Polyline.
In short, I want to know the covered or traveled points on Polyline
回答1:
you need to measure the distance between you and all points then find the nearest point to tell you what point. try to add threshold between you and nearest point to make sure that you are on the polyline errors could happen because of location read accuracy.
to measure a distance between two location you need to write this code.
locationA.distanceTo(locationB);
来源:https://stackoverflow.com/questions/52016863/how-to-compare-locations