OGeek|极客世界-中国程序员成长平台

标题: iphone - 从当前位置导航到放置的图钉 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:45
标题: iphone - 从当前位置导航到放置的图钉

我有一个 map View ,里面有一个丢弃的图钉,我想做的是显示从用户当前位置到丢弃的图钉的路线。

我搜索了它但没有运气,如果有人知道怎么做,请帮忙?

提前致谢。



Best Answer-推荐答案


试试看……

你可以通过两种方式做到这一点:
1.

CLLocationCoordinate2D start = { c_lat, c_long };
CLLocationCoordinate2D destination = { [[dic valueForKey"business_lat"]doubleValue], [[dic valueForKey"business_long"]doubleValue] };

NSString *googleMapsURLString = [NSString stringWithFormat"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f&",start.latitude, start.longitude, destination.latitude, destination.longitude];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];

2.

使用谷歌 API

请查看this用于绘制两个位置之间的路线

在 API 中你只需要传递源名称和目的地名称

希望我能帮上忙……

关于iphone - 从当前位置导航到放置的图钉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16251847/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4