title: Google map api Parsing travel duration data in swift3
body: <p>I'm trying to parse an estimated travel duration and distance between two waypoints using Google Directions API, I want this on the google map.
  this is the api</p>
  
  <pre><code>   http://maps.googleapis.com/maps/api/directions/json?mode=walking&amp;origin=13.0262523,77.5892838&amp;destination=13.0282523,77.5892838&amp;sensor=false
  </code></pre>
  
  <p>this is the json result</p>
  
  <pre><code>{
     "geocoded_waypoints" : [
        {
           "geocoder_status" : "OK",
           "place_id" : "ChIJlaQiiroXrjsR4yct_s2meO0",
           "types" : [ "street_address" ]
        },
        {
           "geocoder_status" : "OK",
           "place_id" : "EmQxMTAtMTEyLCA3dGggQ3Jvc3MgUmQsIFYgLiBWIE5hZ2FyLCBLYXVzZXIgTmFnYXIsIERpbm51ciwgSGViYmFsLCBCZW5nYWx1cnUsIEthcm5hdGFrYSA1NjAwMzIsIEluZGlh",
           "types" : [ "street_address" ]
        }
     ],
     "routes" : [
        {
           "bounds" : {
              "northeast" : {
                 "lat" : 13.0271681,
                 "lng" : 77.5938656
              },
              "southwest" : {
                 "lat" : 13.0246613,
                 "lng" : 77.593385
              }
           },
           "copyrights" : "Map data ©2018 Google",
           "legs" : [
              {
                 "distance" : {
                    "text" : "0.3 km",
                    "value" : 284
                 },
                 "duration" : {
                    "text" : "2 mins",
                    "value" : 101
                 },
                 "end_address" : "110-112, 7th Cross Rd, V . V Nagar, Kauser Nagar, Dinnur, Hebbal, Bengaluru, Karnataka 560032, India",
                 "end_location" : {
                    "lat" : 13.0271681,
                    "lng" : 77.5938656
                 },
                 "start_address" : "75A, Dinnur Main Rd, P&amp;T Colony, Ganga Nagar, Bengaluru, Karnataka 560032, India",
                 "start_location" : {
                    "lat" : 13.0246613,
                    "lng" : 77.593385
                 },
                 "steps" : [
                    {
                       "distance" : {
                          "text" : "26 m",
                          "value" : 26
                       },
                       "duration" : {
                          "text" : "1 min",
                          "value" : 8
                       },
                       "end_location" : {
                          "lat" : 13.0248884,
                          "lng" : 77.59343510000001
                       },
                       "html_instructions" : "Head \u003cb\u003enorth\u003c/b\u003e toward \u003cb\u003eDinnur Main Rd\u003c/b\u003e",
                       "polyline" : {
                          "points" : "c{nnAs}qxMm@K"
                       },
                       "start_location" : {
                          "lat" : 13.0246613,
                          "lng" : 77.593385
                       },
                       "travel_mode" : "DRIVING"
                    },
                    {
                       "distance" : {
                          "text" : "0.3 km",
                          "value" : 258
                       },
                       "duration" : {
                          "text" : "2 mins",
                          "value" : 93
                       },
                       "end_location" : {
                          "lat" : 13.0271681,
                          "lng" : 77.5938656
                       },
                       "html_instructions" : "At ArchFront Technologies, continue onto \u003cb\u003e7th Cross Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Anjali Mukerjee Health Total RT Nagar (on the left)\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e",
                       "polyline" : {
                          "points" : "q|nnA_~qxMG?qAM}@KSAgBUsDc@"
                       },
                       "start_location" : {
                          "lat" : 13.0248884,
                          "lng" : 77.59343510000001
                       },
                       "travel_mode" : "DRIVING"
                    }
                 ],
                 "traffic_speed_entry" : [],
                 "via_waypoint" : []
              }
           ],
           "overview_polyline" : {
              "points" : "c{nnAs}qxMeEe@oH{@"
           },
           "summary" : "7th Cross Rd",
           "warnings" : [],
           "waypoint_order" : []
        }
     ],
     "status" : "OK"
  }
  </code></pre>
  
  <p>this is the code </p>
  
  <p>func timedistanceupdate()
     {</p>
  
  <pre><code> let request = URLRequest(url: URL(string: "http://maps.googleapis.com/maps/api/directions/json?&amp;mode=driving&amp;origin=\(currentlatlong)&amp;destination=\(latlng)&amp;sensor=false")!)
  
  let session = URLSession.shared
  
  let task = session.dataTask(with:request,completionHandler:{(d,response,error)in
  
      do{
  
  
          if let data = d{
              do{
  
                  let jsonResult = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as! NSDictionary
  
  
                   if let studentsdata1 = jsonResult["routes"] as? NSArray {
  
                      if studentsdata1.count &gt; 0 {
  
                       if let legs = studentsdata1[0]["legs"] as? NSArray
  
                       {
  
                          if legs.count &gt; 0 {
  
                               if let duration = legs[0]["duration"] as? NSDictionary {
  
                              }
  
                          }
                          }
                      }
  
                  }
  
  
              } catch
              {
  
              }
  
          }
  
      }
  })
  task.resume()
  }
  </code></pre>
  
  <p>I searched lot of way I din't find any thing,I want print the time duration  and distance between two location in label on google map </p>