Move a LatLng 5 meters towards another LatLng

2020-06-17 04:57发布

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条回答
一纸荒年 Trace。
2楼-- · 2020-06-17 05:35

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

查看更多
登录 后发表回答