Move a LatLng 5 meters towards another LatLng

2020-06-17 05:08发布

问题:

What algorithm/formula can I use to calculate a LatLng point 5 meters closer to another LatLng point? I'm trying to write a function with 2 LatLng parameters and have it return a LatLng that is 5 meters from the first LatLng and in the direction of the second LatLng.

回答1:

Have a look at Android Map Utils library, specifically the SphericalUtil class.

1.) Call the method computeHeading to obtain your heading from first to second

2.) Call the method computeOffset to solve for the location 5 meters from your first point

Hope this helps