How do I get the duration from one location to another?

10 views
Skip to first unread message

novarse

unread,
Aug 12, 2010, 7:10:21 AM8/12/10
to gwt-maps3-discuss
Hi,
Can you please tell me how to obtain the time taken to get from place
to another? I can't figure it out.
Thank you

Vinay

unread,
Aug 12, 2010, 1:03:17 PM8/12/10
to novarse, gwt-maps3-discuss
DirectionsLeg has a method getDuration();

novarse

unread,
Aug 14, 2010, 11:04:33 PM8/14/10
to gwt-maps3-discuss
Hi Vinay,
I tried the code below, which works well except when I include the
'request.setUnitSystem("METRIC");' line which results in an error:
com.google.gwt.core.client.JavaScriptException: (Error): Invalid value
for property <unitSystem>: METRIC

Also can you please tell me when might this project be merged into gwt-
google-apis?

Thanks
stephen


private void getDuration() {
DirectionsRequest request = new DirectionsRequest();
request.setDestinationString("penn station, new york, ny");
request.setOriginString("grand central station, new york, ny");
request.setTravelMode("DRIVING");
request.setUnitSystem("METRIC");

DirectionsService dirService = new DirectionsService();
dirService.route(request, new DirectionsCallback() {

@Override
public void callback(HasDirectionsResult response, String status) {
if (status.equals("OK")) {
DirectionsLeg dl = (DirectionsLeg) response.getRoutes()
.get(0).getLegs().get(0);
System.out.println("Distance: "
+ dl.getDistance().getText() + "; Duration: "
+ dl.getDuration().getText());
}
}
});

Camilo Montes

unread,
Aug 16, 2010, 9:37:38 AM8/16/10
to gwt-maps3-discuss
Hi Stephen, i post an issue for the error you are getting, see
http://code.google.com/p/gwt-google-maps-v3/issues/detail?id=19
there has not been a patch release for this issue yet. You can add it
to favorites so you'll get notified for any changes.
Cheers,

Camilo
Reply all
Reply to author
Forward
0 new messages