How to open the device map in the "My iphone" application to draw the path between the source and destination?

I want to open the device map in the "My Iphone Application" application to draw a path between the source and destination, as shown below.

enter image description here

How to open the device map in my iphone application as shown above?

+4
source share
1 answer

Use the code below to open the Maps app,

NSString *url; if([[[UIDevice currentDevice] systemVersion] compare:@"6.0" options:NSNumericSearch] == NSOrderedAscending) { url = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%@,%@&saddr=%@,%@",[dict objectForKey:@"latitude"],[dict objectForKey:@"longitude"],currentLat,currentLong]; } else { url = [NSString stringWithFormat:@"http://maps.apple.com/maps?daddr=%@,%@&saddr=%@,%@",[dict objectForKey:@"latitude"],[dict objectForKey:@"longitude"],currentLat,currentLong]; } if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; } 

iOS 6.0 and above has an Apple Map app for the lower version of iOS, you need to open the Google Map app. Here in url,

 daddr=%@,%@&saddr=%@,%@ 

daddr is the destination address, and saddr is the source address.

+3
source

All Articles