2016-11-11 2 views
0

私は、このような緯度と経度のリストについては、GoogleマップクライアントのJava APIを使用してGoogleマップの経路を最適化する方法。

DirectionsRoute[] routes = DirectionsApi.newRequest(context) 
       .mode(TravelMode).origin(startPoint).destination(endPoint) 
       .waypoints(wayPoints).await(); 

をルートの詳細を取得していますが、私は最適化されていません取得していたルートはので、私はGoogleのJavaクライアントAPIを使用してルートを最適化したいです。

我々はこの

{ 
    origin: LatLng | String | google.maps.Place, 
    destination: LatLng | String | google.maps.Place, 
    travelMode: TravelMode, 
    drivingOptions: DrivingOptions, 
    waypoints[]: DirectionsWaypoint, 
    optimizeWaypoints: boolean 
} 

のようなブール属性を与えることによって最適化することができます。しかし、この使用して、GoogleマップのJavaクライアントAPIを達成するためにどのようにJavaScript APIのグーグルマップで

答えて

1

optimizeWaypointsメソッドを使用できます。あなたのコードでは

dependencies { 
    compile 'com.google.maps:google-maps-services:0.1.16' 
} 

<dependency> 
    <groupId>com.google.maps</groupId> 
    <artifactId>google-maps-services</artifactId> 
    <version>0.1.16</version> 
</dependency> 

:あなたはグーグル・マップ・サービスの最新の(0.1.16)のバージョンを使用していることを確認してください

DirectionsRoute[] routes = DirectionsApi.newRequest(context) 
    .mode(TravelMode) 
    .origin(startPoint) 
    .destination(endPoint) 
    .waypoints(wayPoints) 
    .optimizeWaypoints(true) // Add this 
    .await(); 
+0

おかげで役立つが、この方法では、Googleマップサービスで利用可能であるかどうかバージョン0.1.1 –

関連する問題