List of usage examples for com.google.gwt.maps.client.services DirectionsRequest setWaypoints
public final native void setWaypoints(JsArray<DirectionsWaypoint> waypoints) ;
From source file:com.google.gwt.maps.testing.client.maps.DirectionsServiceMapWidget.java
License:Apache License
private void drawDirectionsWithMidPoint() { DirectionsRendererOptions options = DirectionsRendererOptions.newInstance(); final DirectionsRenderer directionsDisplay = DirectionsRenderer.newInstance(options); directionsDisplay.setMap(mapWidget); String origin = "Arlington, WA"; String destination = "Seattle, WA"; DirectionsRequest request = DirectionsRequest.newInstance(); request.setOrigin(origin);/*from ww w. j av a 2s . co m*/ request.setDestination(destination); request.setTravelMode(TravelMode.DRIVING); request.setOptimizeWaypoints(true); // Stop over LatLng stopOverWayPoint = LatLng.newInstance(47.8587, -121.9697); DirectionsWaypoint waypoint = DirectionsWaypoint.newInstance(); waypoint.setStopOver(true); waypoint.setLocation(stopOverWayPoint); JsArray<DirectionsWaypoint> waypoints = JsArray.createArray().cast(); waypoints.push(waypoint); request.setWaypoints(waypoints); DirectionsService o = DirectionsService.newInstance(); o.route(request, new DirectionsResultHandler() { public void onCallback(DirectionsResult result, DirectionsStatus status) { if (status == DirectionsStatus.OK) { directionsDisplay.setDirections(result); getDistance(); } else if (status == DirectionsStatus.INVALID_REQUEST) { } else if (status == DirectionsStatus.MAX_WAYPOINTS_EXCEEDED) { } else if (status == DirectionsStatus.NOT_FOUND) { } else if (status == DirectionsStatus.OVER_QUERY_LIMIT) { } else if (status == DirectionsStatus.REQUEST_DENIED) { } else if (status == DirectionsStatus.UNKNOWN_ERROR) { } else if (status == DirectionsStatus.ZERO_RESULTS) { } } }); }