DIRECTION_URL_API = "https://maps.googleapis.com/maps/api/directions/json?"
DIRECTION_URL_API + "origin=" + origin + "&destination=" + destination + "&sensor=true" + "&mode=" +typeOpt+"&key=" + GOOGLE_API_KEY ;
我正在使用这种格式,但它不起作用
请建议我:)。
答案 0 :(得分:0)
原点= LAT1,long1 目的地= LAT2,long2
答案 1 :(得分:0)
请使用以下方法计算两点
之间的距离/**
* Returns Distance in kilometers (km)
*/
public static String distance(double startLat, double startLong, double endLat, double endLong) {
Location startPoint = new Location("locationA");
startPoint.setLatitude(startLat);
startPoint.setLongitude(startLong);
Location endPoint = new Location("locationA");
endPoint.setLatitude(endLat);
endPoint.setLongitude(endLong);
return String.format("%.2f", startPoint.distanceTo(endPoint) / 1000); //KMs
}
方法用法 -
String mDistance = distance(startLat,
startLong,
endLat,endLng)).concat("km");