I am trying to find the duration of travel from source to destination using google api services. I need to find out the duration of the trip in accordance with traffic conditions. I tried using javascript and it returns the duration of the traffic. But when I tried the same problem in java, it does not seem to return the duration of the traffic. So, how to get the duration in traffic using google api referral services?
URL url = new URL ("http://maps.googleapis.com/maps/api/directions/json?origin=" + URLEncoder.encode(origin, "UTF-8") +"&destination="+ URLEncoder.encode(destination, "UTF-8") +"&waypoints=optimize:true|Bagbazar,Kathmandu|Thapathali,Kathmandu|Kamal+Pokhari,Kathmandu"+"&sensor=false");
Above, I inserted the url that I used to send to google server. Below is the java script code, in the following code I can set durationInTraffic: true, which returns the time it takes to move through the traffic conditions. What is an equivalent process in java?
var request = { origin:"Wollongong, Australia", destination:"Sydney,Australia", travelMode: google.maps.DirectionsTravelMode.DRIVING, provideRouteAlternatives: true, durationInTraffic: true };
source share