Open a map URL with MapKit
I was wondering how can I open a google map URL with MapKit ?
this code exit the application and shows the location but I want shows on my mapView.
NSString *urlString = @"http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cuper开发者_开发问答tino";
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: urlString]];
MapKit supports Geolocation - so how about something like this:
CLLocation *sanFran = [CLLocation locationUsingForwardGeoLocation:@"San Francisco, Califronia"];
This returns a CLLocation which you can then show on your map view.
Have a look at the World Cities sample code (iOS dev membership required) which shows how to animate an MKMapView to coordinates.
Edited to add
There are ways to get the Lat-long with Google Tools. You can use these to create a CLLocation as well.
You can use UIWebview to load the contents of the url. Create a webView and initialise as follows:
NSString *urlString = @"http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino";
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString: urlString]];
[webView loadRequest:req];
Yeah you should add this webview as a subview to your main view.
精彩评论