How do I get directions using Google Maps on iOS?

Good afternoon! I integrated google maps into my app and plot a route from point to point on the map. On the map, the route is drawn using polyline and a request to the google direction api. But this is not a very accurate and beautiful way - if the road on the map runs in an arc, then the line is drawn straight(

How do I make the line draw more accurately, that is, on the road, and not on top of the houses?

Author: Jane, 2015-07-24

1 answers

About 2 years ago, I had the same task to plot a route. I tried to use your method too. But it did not bring me the desired effect. I used three options. The user can choose for himself. This is to plot a route through the Maps app (this method is described in the book Sadun, there is also a code). It turns out that this is the request:

maps://?saddr=50.039551,36.356758&daddr=50.040218,36.356968&zoom=12&directionsmode=walking

The second method is via the Google Maps app. I found this on their website. The following query is obtained:

comgooglemaps://?saddr=50.042637,36.353310&daddr=50.040211,36.356953&zoom=12&directionsmode=walking&key=AIzaSyCYDDO89sWhrgunAG6R0pcnkX3ot5Yel28

And finally the way when the route laid out in Safari. It is always on the device. Here we get the following request:

http://maps.google.com/maps?saddr=50.039551,36.356758&daddr=50.040218,36.356968&zoom=12&directionsmode=walking&key=AIzaSyBrJxnPNN_nYbrL1GuWFPqvvMqTnO37ir4

Outwardly, everything looks beautiful. The user can select both the map type and the transport type in Maps or Google Maps. There are many different features that are difficult to repeat in your application. I agree, this is not quite the answer to your question. But perhaps it will give an impulse for reflection.

MKDirections - solution to the problem. Here is a detailed example. And not just how plot a route, but also place an annotation on the map.

 1
Author: stosha, 2015-09-21 05:14:10