MKMapView Route/Directions

Mark picture Mark · Sep 29, 2009 · Viewed 17.8k times · Source

I found that the Google Maps API supports Directions through:

var map;
var directionsPanel;
var directions;

function initialize() {
  map = new GMap2(document.getElementById("map_canvas"));
  directionsPanel = document.getElementById("my_textual_div");
  map.setCenter(new GLatLng(49.496675,-102.65625), 3);
  directions = new GDirections(map, directionsPanel);
  directions.load("from: 500 Memorial Drive, Cambridge, MA to: 4 Yawkey Way, Boston, MA 02215 (Fenway Park)");
}

So how can this be translated into Objective-C so it can be retrieved by the iPhone? I know how to draw a line on MKMapView I just need the geolocations for the route.

Or perhaps there is a different way to get the route between two geolocation points.

Please let me know,

Thanks in advance.

Answer

coffeemate picture coffeemate · May 31, 2010

There is an undocumented Google Maps Directions API mentioned and exposed here

Also you should take a look at the sample IPhone application which draws routes/directions onto MKMapView using the API mentioned above here

But warning you about the licencing issues about the undocumented Google Maps Directions API.

Hope this helps.