I am new to google maps and Flutter and I was wondering if it is possible to retrieve the walking distance and duration when the user enters their destination.
For example, a user enters their workplace destination. The walking distance from this user's house to the bus stop would be the first distance and duration to retrieve and then when the user alights from the bus, the walk from the bus stop to the work place is another distance and duration to retrieve.
Here I am using the sample responses from the directions API documentation. https://developers.google.com/maps/documentation/directions/intro#DirectionsResponseElements
class GoogleMapsServices{
Future<String> getRouteCoordinates()async{
String url = "https://maps.googleapis.com/maps/api/directions/json?
origin=Chicago,IL&destination=Los+Angeles,CA
&waypoints=Joplin,MO|Oklahoma+City,OK &key=$apiKey";
http.Response response = await http.get(url);
print (response.body);
Map values = jsonDecode(response.body);
return values["routes"][0]["overview_polyline"]["points"];
}
}
Currently I have these codes and looking at the response.body, I am able to retrieve the entire journey arrival time and so on but not the walking distance and duration to the bus stops and away from the bus stops. Is this possible to be done?
I am getting these results when I print the response.body
I/flutter (23129): {
I/flutter (23129): "geocoded_waypoints" : [
I/flutter (23129): {
I/flutter (23129): "geocoder_status" : "OK",
I/flutter (23129): "place_id" : "ChIJ7cv00DwsDogRAMDACa2m4K8",
I/flutter (23129): "types" : [ "locality", "political" ]
I/flutter (23129): },
I/flutter (23129): {
I/flutter (23129): "geocoder_status" : "OK",
I/flutter (23129): "place_id" : "ChIJ69Pk6jdlyIcRDqM1KDY3Fpg",
I/flutter (23129): "types" : [ "locality", "political" ]
I/flutter (23129): },
I/flutter (23129): {
I/flutter (23129): "geocoder_status" : "OK",
I/flutter (23129): "place_id" : "ChIJgdL4flSKrYcRnTpP0XQSojM",
I/flutter (23129): "types" : [ "locality", "political" ]
I/flutter (23129): },
I/flutter (23129): {
I/flutter (23129): "geocoder_status" : "OK",
I/flutter (23129): "place_id" : "ChIJE9on3F3HwoAR9AhGJW_fL-I",
I/flutter (23129): "types" : [ "locality", "political" ]
I/flutter (23129): }
I/flutter (23129): ],
I/flutter (23129): "routes" : [
I/flutter (23129): {
I/flutter (23129): "bounds" : {
I/flutter (23129): "northeast" : {
I/flutter (23129): "lat" : 41.8781139,
I/flutter (23129): "lng" : -87.6297872
I/flutter (23129): },
I/flutter (23129): "southwest" : {
I/flutter (23129): "lat" : 34.0523523,
I/flutter (23129): "lng" : -118.2435731
I/flutter (23129): }
I/flutter (23129): },
I/flutter (23129): "copyrights" : "Map data ยฉ2019 Google, INEGI",
I/flutter (23129): "legs" : [
I/flutter (23129): {
I/flutter (23129):
Thanks.