2017-02-21 5 views
0

GoogleのDirection APIを使用して、ソースとターゲットの間に運転経路を描いています。複数の代替ルートを表示したいので、パラメータ alternatives=trueをURL文字列に渡します。しかし、余分なパスは表示されず、1つだけ表示されます。 URLのための私のコード:GoogleディレクションAPIで「alternatives = true」が機能しない

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

選択肢 - trueに設定されている場合は、ルートサービスが 応じて複数のルートの代替を提供することができることを指定します。代替ルートを提供する は、 サーバーからの応答時間を増加させる可能性があることに注意してください。

あなたはいつも選択肢を得るとは限りません!

Source

+0

理由を詳しく教えてください。サーバからの応答が遅いという特定の分野に課されている制限のためですか? –

+0

@RajaShahrozeAbbasなぜ彼らはいつも選択肢を送信するわけではないかもしれませんが、それは多くの理由が原因である可能性があります。代替手段がないか、無料使用パッケージに制限している可能性があります。 ](https://developers.google.com/maps/documentation/directions/usage-limits) –

+0

助けを借りて大丈夫です:D –

関連する問題