【发布时间】:2011-09-30 04:14:01
【问题描述】:
在我的 iPhone 应用程序中如何显示从当前位置到终点的路线?
iphone 上是否有任何内置组件或设施可以使用 GPS 和内置指南针显示地图和方向?
【问题讨论】:
-
如果我想使用 MKMap 在我的应用中显示此路线怎么办..!?
标签: iphone objective-c ios4 google-maps gps
在我的 iPhone 应用程序中如何显示从当前位置到终点的路线?
iphone 上是否有任何内置组件或设施可以使用 GPS 和内置指南针显示地图和方向?
【问题讨论】:
标签: iphone objective-c ios4 google-maps gps
如果您的意思是基于两点将用户带到地图应用程序,那么您可以这样做:
NSURL *URL = [NSURL URLWithString:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f"];
您适当地插入您的起始地址和目的地(经纬度)。 [[UIApplication sharedApplication] openURL:URL];
它应该会自动带您进入地图应用程序!
【讨论】:
试试这个:-
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]];
【讨论】:
NSString *Urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%@&daddr=%@",from_address,to_address];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];
这将给出明确的方向,提及源地址和目标地址。
【讨论】: