Search code examples
google-mapsgoogle-distancematrix-api

How to find distance between two coordinates using google maps SDK for ios?


I have an ios application which uses default Apple map for displaying selected records on map. Now I have to add a button "Drive Route" which launches google maps installed on device and show direction from current location to selected records .I already did this by using Google Maps URL Scheme for ios.

Now i want to know the distance and Travel time between selected records and current location. I found that we can do this by using Distance Matrix API like this :

"https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=(a_coordinate_string)&destinations=(b_coordinate_string)&key=<#GOOGLE_API_KEY#>"

But I want to use Google Maps SDK methods to get desired result.

  • NOTE : I have used Places SDK for ios , where we have Methods AutocompleteQuery () etc.

Does Google Map SDK provide any Methods to get desired Distance and Travel time?

Please, help me. Thanks in advance.


Solution

  • Google Maps SDKs currently do not have this kind of feature. You will need get the results programmatically via Distance Matrix Web Service request.

    If you would like to have this feature available in the Google Maps SDKs, you may file this as a feature request in Public Issue Tracker: https://developers.google.com/maps/support/#issue_tracker