iPhone App :show direction using Map

我们两清 提交于 2019-12-06 16:03:21

If you mean taking the user to the maps application based on two points, then you can do it like this:

  1. 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.
  2. Tell your application to open the URL [[UIApplication sharedApplication] openURL:URL];

It should take you to the maps application automatically!

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]];
Rama Rao
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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!