我需要得到两个位置之间的距离,但我需要像图片中的蓝线那样获得距离。 获取android中两个位置之间的距离?
下一个我尝试:
public double getDistance(LatLng LatLng1, LatLng LatLng2) {
double distance = 0;
Location locationA = new Location("A");
locationA.setLatitude(LatLng1.latitude);
locationA.setLongitude(LatLng1.longitude);
Location locationB = new Location("B");
locationB.setLatitude(LatLng2.latitude);
locationB.setLongitude(LatLng2.longitude);
distance = locationA.distanceTo(locationB);
return distance;
}
,但我得到的红线距离。
嗨, 你不需要谷歌地图在使用数学[http://www.movable-type.co.uk/scripts/latlong.html][1] 谢谢 – Felquir
如果你想计算的路线,而不是红线的距离比你将不得不使用谷歌API!这将返回距离和估计的时间来覆盖距离! –
它只是返回两个位置的距离计算....如果你想红线,然后使用Google API。 – Piyush