开发者

Open a map URL with MapKit

开发者 https://www.devze.com 2023-03-13 05:12 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消