Android &引用;备选方案=正确的“;不在Google Direction API中工作
我正在使用谷歌的DirectionAPI在源和目标之间绘制一条驱动路径。我想显示多个备选路线,以便传递参数 URL字符串中的Android &引用;备选方案=正确的“;不在Google Direction API中工作,android,google-maps,google-directions-api,Android,Google Maps,Google Directions Api,我正在使用谷歌的DirectionAPI在源和目标之间绘制一条驱动路径。我想显示多个备选路线,以便传递参数 URL字符串中的alternations=true。但它不显示任何额外路径,只显示一条。 我的URL代码: Private String getDirectionsUrl(LatLng origin,LatLng dest) { // Origin of route String str_origin = "origin="+origin.latitude+","+orig
alternations=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;
}
备选方案-如果设置为true,则指定方向服务
可在响应中提供多个备选路线。注意
提供路线备选方案可能会增加从
服务器
你不会总是有其他选择
你能解释一下原因吗?这是因为对服务器响应缓慢的特定区域施加了限制吗?@Rajashahrozeabas我不确定他们为什么不总是发送替代方案,但这可能是由于许多原因,也许没有别的选择,也可能是他们限制了免费使用软件包,这对你的用法有很多限制,请看@ RajaShahrozeAbbas欢迎你,请考虑接受我的答案,让其他人知道正确的选择: