swift - How to get turn by turn navigations using an array of Latitudes and longitudes? -
i trying create turn turn navigation interface. have tried using google's api , have collected sub starting , ending latitudes , longitudes in betweek 2 places like
a : starting point , b: ending point
a -> c -> d -> e -> b
now have array a's cordinates , c's cordinates. , want make c starting point , d ending point , on.
func getdirections(){ navapi.shared.signin(origin: "malkajgiri", destination: "safilguda") { (response) in if response.success == false{ print(response.message!) }else{ guard let jsonobject = response.jsonobject as? [string:anyobject] else {return } guard let routes = jsonobject["routes"] as? nsarray else {return } guard let items = routes[0] as? [string:any] else {return } guard let legs = items["legs"] as? nsarray else {return } guard let item = legs[0] as? [string:any] else {return } guard let steps = item["steps"] as? nsarray else {return } in steps{ guard let items = as? [string:any] else {return } guard let distance = items["distance"] as? [string:any] else {return } guard let distancetext = distance["text"] as? string else {return } guard let duration = items["duration"] as? [string:any] else {return } guard let durationtext = duration["text"] as? string else {return } guard let end_location = items["end_location"] as? [string:any] else {return } guard let end_locationlat = end_location["lat"] as? float else {return } guard let end_locationlon = end_location["lng"] as? float else {return } guard let start_location = items["start_location"] as? [string:any] else {return } guard let start_locationlat = start_location["lat"] as? float else {return } guard let start_locationlon = start_location["lng"] as? float else {return } guard var html = items["html_instructions"] as? string else {return } // html = html.replacingoccurrences(of: "<[^>]+>", with: "", options: string.compareoptions.regularexpression, range: nil) self.distances.append(distancetext) // distances c, d etc stored in array self.durations.append(durationtext)// durations each distance c, d etc stored in array self.endlats.append(end_locationlat)// end lat values c, d etc stored in array self.endlongs.append(end_locationlon)// end long values c, d etc stored in array self.startlats.append(start_locationlat)// start lat values c, d etc stored in array self.startlongs.append(start_locationlon)// starting long values c, d etc stored in array self.htmlinstructions.append(html)// instructions c, d etc stored in array } } } }
how can check current user's cordinates cordinates in array (starting point ) , guid user end point showing distance travel there ?
can give me insights of how acheive this
Comments
Post a Comment