简体   繁体   中英

Open Native Map app from My App in iPhone

I want to open native map application from my application by Clicking on Button. How i can do This ?

NSString *mapUrl= [NSString stringWithFormat:@"https://maps.google.com/maps?ll=%f,%f",Latitude ,Longitude];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mapUrl]];
NSString *title = @"any title";
float latitude = 75.4634;
float longitude = 69.43425;
int zoom = 13;
NSString *stringURL = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%1.6f,%1.6f&  z=%d", title, latitude, longitude, zoom];
NSURL *url = [NSURL URLWithString:stringURL];   
[[UIApplication sharedApplication] openURL:url];

Have a look at below code, it will satisfy your need.

NSString *title = @"title";
float latitude = 35.4634;
float longitude = 9.43425;
int zoom = 13;
NSString *stringURL = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%1.6f,%1.6f&z=%d", title, latitude, longitude, zoom];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Cheers!

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