Android Question help json google map

Prosg

Active Member
Licensed User
Longtime User
Hello
i need in a job.done to have only this


"distance" : {
"text" : "1 m",

and

"duration" : {
"text" : "1 minute",


http://maps.googleapis.com/maps/api....7727185,4.852051&mode=driving&Language=fr-FR

B4X:
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJxbptqfLq9EcRlxYqj3eXILY",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJxbptqfLq9EcRlxYqj3eXILY",
"types" : [ "street_address" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 45.7725132,
"lng" : 4.852093
},
"southwest" : {
"lat" : 45.7725132,
"lng" : 4.852093
}
},
"copyrights" : "Données cartographiques ©2016 Google",
"legs" : [
{
"distance" : {
"text" : "1 m",
"value" : 0
},
"duration" : {
"text" : "1 minute",
"value" : 0
},
"end_address" : "2 Rue Jacques de Boissieu, 69006 Lyon, France",
"end_location" : {
"lat" : 45.7725132,
"lng" : 4.852093
},
"start_address" : "2 Rue Jacques de Boissieu, 69006 Lyon, France",
"start_location" : {
"lat" : 45.7725132,
"lng" : 4.852093
},
"steps" : [
{
"distance" : {
"text" : "1 m",
"value" : 0
},
"duration" : {
"text" : "1 minute",
"value" : 0
},
"end_location" : {
"lat" : 45.7725132,
"lng" : 4.852093
},
"html_instructions" : "Prendre \u003cb\u003eRue Jacques de Boissieu\u003c/b\u003e",
"polyline" : {
"points" : "e}jvGqtr\\"
},
"start_location" : {
"lat" : 45.7725132,
"lng" : 4.852093
},
"travel_mode" : "DRIVING"
}
],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "e}jvGqtr\\"
},
"summary" : "Rue Jacques de Boissieu",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}

i test with
B4X:
Dim DistanceKm As List
DistanceKm.Initialize
Dim root As Map = parser.NextObject
Dim results As List = root.Get("routes")
        For Each colresults As Map In results
               ....... But after ? 
        Next
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim routes As List = root.Get("routes")
For Each colroutes As Map In routes
Dim summary As String = colroutes.Get("summary")
Dim copyrights As String = colroutes.Get("copyrights")
Dim legs As List = colroutes.Get("legs")
For Each collegs As Map In legs
  Dim duration As Map = collegs.Get("duration")
  Dim text As String = duration.Get("text")
  Dim value As Int = duration.Get("value")
  Dim start_location As Map = collegs.Get("start_location")
  Dim lng As Double = start_location.Get("lng")
  Dim lat As Double = start_location.Get("lat")
  Dim distance As Map = collegs.Get("distance")
  Dim text As String = distance.Get("text")
  Dim value As Int = distance.Get("value")
  Dim start_address As String = collegs.Get("start_address")
  Dim end_location As Map = collegs.Get("end_location")
  Dim lng As Double = end_location.Get("lng")
  Dim lat As Double = end_location.Get("lat")
  Dim end_address As String = collegs.Get("end_address")
  Dim via_waypoint As List = collegs.Get("via_waypoint")
  Dim steps As List = collegs.Get("steps")
  For Each colsteps As Map In steps
   Dim duration As Map = colsteps.Get("duration")
   Dim text As String = duration.Get("text")
   Dim value As Int = duration.Get("value")
   Dim start_location As Map = colsteps.Get("start_location")
   Dim lng As Double = start_location.Get("lng")
   Dim lat As Double = start_location.Get("lat")
   Dim distance As Map = colsteps.Get("distance")
   Dim text As String = distance.Get("text")
   Dim value As Int = distance.Get("value")
   Dim travel_mode As String = colsteps.Get("travel_mode")
   Dim html_instructions As String = colsteps.Get("html_instructions")
   Dim end_location As Map = colsteps.Get("end_location")
   Dim lng As Double = end_location.Get("lng")
   Dim lat As Double = end_location.Get("lat")
   Dim polyline As Map = colsteps.Get("polyline")
   Dim points As String = polyline.Get("points")
  Next
Next
Dim warnings As List = colroutes.Get("warnings")
Dim bounds As Map = colroutes.Get("bounds")
Dim southwest As Map = bounds.Get("southwest")
Dim lng As Double = southwest.Get("lng")
Dim lat As Double = southwest.Get("lat")
Dim northeast As Map = bounds.Get("northeast")
Dim lng As Double = northeast.Get("lng")
Dim lat As Double = northeast.Get("lat")
Dim overview_polyline As Map = colroutes.Get("overview_polyline")
Dim points As String = overview_polyline.Get("points")
Dim waypoint_order As List = colroutes.Get("waypoint_order")
Next
Dim geocoded_waypoints As List = root.Get("geocoded_waypoints")
For Each colgeocoded_waypoints As Map In geocoded_waypoints
Dim types As List = colgeocoded_waypoints.Get("types")
For Each coltypes As String In types
Next
Dim geocoder_status As String = colgeocoded_waypoints.Get("geocoder_status")
Dim place_id As String = colgeocoded_waypoints.Get("place_id")
Next
Dim status As String = root.Get("status")
 
Upvote 0
Top