我需要打开地图从我的应用程序已经跟踪的路线。起点是用户的位置(已经有了),终点是我有经度和纬度的设施。
通过查看MapLinks上的苹果文档,我发现可以将地址作为字符串传递,但我没有看到任何关于lat+long的信息。
以前有人这样做过吗?有可能吗?
发布于 2014-04-08 13:35:18
这是非常可能的。不要传递地址,只需在字符串中传递lat和lon值,用逗号分隔。例如,如果您想打开地图应用程序,其中包含当前用户的lat/lon位置和到帝国大厦的方向,则可以插入
CLLocationCoordinate2D empireStateLocation = CLLocationCoordinate2DMake(40.7484, -73.9857);
NSString *queryString = [NSString stringWithFormat:@"http://maps.apple.com/?saddr=%f,%f&daddr=%f,%f", mapView.userLocation.coordinate.latitude, mapView.userLocation.coordinate.longitude, empireStateLocation.latitude, empireStateLocation.longitude];
NSURL *url = [NSURL URLWithString:queryString];
[[UIApplication sharedApplication] openURL:url];https://stackoverflow.com/questions/22938470
复制相似问题