我正在使用Google的Direction API在源和目标之间绘制一条行车路径。我想显示多个替代路由,所以我传递参数
URL字符串中的alternatives=true
。但它不会显示任何额外路径,只会显示一条路径。
我的URL代码:
Private String getDirectionsUrl(LatLng origin,LatLng dest)
{
// Origin of route
String str_origin = "origin="+origin.latitude+","+origin.longitude;
// Destination of route
String str_dest = "destination="+dest.latitude+","+dest.longitude;
// Sensor enabled
String sensor = "sensor=false";
//Adding Alternative parameter
String alternative = "alternatives=true";
// Building the parameters to the web service
String parameters = str_origin+"&"+str_dest+"&"+sensor+"&"+alternative;
// Output format
String output = "json";
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/directions/"+output+"?"+parameters;
return url;
}
答案 0 :(得分:0)