"alternatives=true" 无法在 Google 方向工作 API
"alternatives=true" not working in Google Direction API
我正在使用 Google 的方向 API 绘制源和目的地之间的行驶路径。我想显示多条替代路线,所以我传递了参数
alternatives=true
在 URL 字符串中。但它不显示任何额外的路径,而只显示一个。
我的 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;
}
alternatives — If set to true, specifies that the Directions service
may provide more than one route alternative in the response. Note that
providing route alternatives may increase the response time from the
server.
你不会总是有替代品!
我正在使用 Google 的方向 API 绘制源和目的地之间的行驶路径。我想显示多条替代路线,所以我传递了参数
alternatives=true
在 URL 字符串中。但它不显示任何额外的路径,而只显示一个。
我的 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;
}
alternatives — If set to true, specifies that the Directions service may provide more than one route alternative in the response. Note that providing route alternatives may increase the response time from the server.
你不会总是有替代品!