While I am using Google Maps SDK, I am trying to get driving direction between two locations on iOS. I know we can do this using two methods:-
1.) Using URL Scheme, for which it is necessary that Google Maps App is installed on your device.
2.) Using Directions API, via Request-Response and then parsing the JSON. Displaying markers to show the direction.
Now, my question is there any other way by which I can do this on iOS? I need to show the direction from my current location to a particular location of which i have the Lat/Long.
I mean is it really not possible to simply pass 2 location as parameter and Google Maps SDK, will give me the directions?
Thanks,
Note: make Sure Your Google Direction API Sdk Is Enable in Your google developer Console.
Swift 4.1, Xcode 9.4.1
Here, you need to add your key (google api key) to the above API.
If someone is looking to parse the distance from routes array following is the way to get the distance in swift 4/5
It sounds like you are looking for UI Chrome like the Google Maps app has for showing directions. Google Maps SDK for iOS will paint you a map, but you are responsible for the additional navigation chrome.
You can use the Google Directions API to request directions, and then use the encoded path returned from the service to draw a GMSPolyline using GMSPath's pathFromEncodedPath: method.
Swift 3.0 & XCode 8.0 Using AFNetworking & SwiftJson
Using Swift I definitely solved in this way.
My purpose was finding distance between two coordinates: