問題描述
我可以使用什么算法/公式來計算距離另一個 LatLng 點更近 5 米的 LatLng 點?我正在嘗試編寫一個帶有 2 個 LatLng 參數的函數,并讓它返回一個距離第一個 LatLng 5 米且朝向第二個 LatLng 的 LatLng.
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.
推薦答案
看看 Android Map Utils 庫,特別是 SphericalUtil 類.
Have a look at Android Map Utils library, specifically the SphericalUtil class.
1.) 調用方法 computeHeading 來獲取你從第一到第二的航向
1.) Call the method computeHeading to obtain your heading from first to second
2.) 調用方法 computeOffset 求解距您的第一個點 5 米的位置
2.) Call the method computeOffset to solve for the location 5 meters from your first point
希望對你有幫助
這篇關于將一個 LatLng 向另一個 LatLng 移動 5 米的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!