问题
in My iPhone App How Can I show directions from current location to End Point?
is there any built in component or facility available on iphone which can show maps and direction using GPS and built in compass?
回答1:
If you mean taking the user to the maps application based on two points, then you can do it like this:
- Create an NSURL that looks like this:
NSURL *URL = [NSURL URLWithString:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f"];You plug in your starting address and destination (in lat. and long.) appropriately. - Tell your application to open the URL
[[UIApplication sharedApplication] openURL:URL];
It should take you to the maps application automatically!
回答2:
try this:-
NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f",sourcelocation.latitude,sourcelocation.longitude,destinationlocation.latitude,destinationlocation.longitude];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];
回答3:
NSString *Urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%@&daddr=%@",from_address,to_address];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];
This will give clear direction mentioning the source address and destination address.
来源:https://stackoverflow.com/questions/7605879/iphone-app-show-direction-using-map