0
我使用Google的方向API绘制源和目标之间的驾驶路径。我想显示多个替代路线,因此我在URL字符串中传递参数 alternatives=true
。但它不显示任何额外的路径,但只有一个。 我对URL代码:“alternatives = true”不适用于Google方向API
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;
}
请您详细说明原因吗?是否因为服务器响应缓慢的特定领域受到限制? –
@RajaShahrozeAbbas我不知道为什么他们可能不会总是发送替代品,但可能是由于很多原因,也许没有其他选择,或者可能是他们限制它在免费使用包上,这对您的使用有许多限制。 ](https://developers.google.com/maps/documentation/directions/usage-limits) –
好的,谢谢你的帮助:D –