简体   繁体   中英

How I can open map with MKMapView?

First off, sorry for my english. I have a problem :( I want to open the map of the city. I can use following construction:

NSString *opMap = [[NSString alloc]
initWithFormat:@"http://maps.google.com/maps?q=new+york+21st+street"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:opMap]];
[opMap release];

But, this - map opens up Safari. I want to open this address (for example New York 21st street(in reality - this address will be provided by a server) with MKMapView. How I can do that?

You can use geocoding and MKMapView . http://files.mettigel-software.com/TSGeocoder.zip is a sample code from my bookmarks, it uses google services. But I am not sure if it violates google's TOS or not.

You should just geocode the address and than show latitude and longitude in MKMapView .

Well, you can open the google maps URL and read the returned HTML and find the string '\\x26ll='. What follows that is the lat/lon pair, comma separated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM