2016-11-11 8 views
0

나는이 같은 위도와 경도의 목록Google지도 클라이언트 자바 API를 사용하여 Google지도에서 경로를 최적화하는 방법.

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

를 경로 정보를 얻고있다하지만 난이 최적화되지 않은 얻고 노선은 그래서 구글 자바 클라이언트 API를 사용하여 경로를 최적화 할 수 있습니다.

우리가이

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

같은 부울 속성을 제공하지만 방법이 사용하여 Google이 매핑 자바 클라이언트 API를 달성하는 방법으로 최적화 할 수 있습니다 자바 스크립트 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

감사의 도움이 있지만,이 방법은 구글지도 서비스에서 사용할 수 있는지 여부 버전 0.1.1 –