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 –