先仔细阅读问题......
我需要直线距离,而不是步行,汽车等.
看看下面给出的这张图片,

谷歌为我们提供驾车和驾车的距离.
但我不想要它,我希望两个位置之间的直线距离(纬度 - 经度).
显示为RED LINE.
注意:我不想在Google地图上放置红线,只想要单位距离(英里,公里等)
Chi*_* Dj 15
ANDROID
double distance
Location locationA = new Location(“point A”)
locationA.setLatitude(latA);
locationA.setLongitude(lngA);
Location locationB = new Location(“point B”);
locationB.setLatitude(latB);
LocationB.setLongitude(lngB);
distance = locationA.distanceTo(locationB);
Run Code Online (Sandbox Code Playgroud)
MATHEMATICALY
a = distance in degrees //meterConversion = 1609;
b = 90 - latitude of point 1
c = 90 - latitude of point 2
l = longitude of point 1 - longitude of point 2
Cos(a) = Cos(b)Cos(c) + Sin(b)Sin(c)Sin(l)
d = circumference of Earth * a / 360 // circumference of Earth = 3958.7558657440545D km
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8601 次 |
| 最近记录: |