【问题标题】:Navigating from current location to dropped pin从当前位置导航到放置的图钉
【发布时间】:2013-05-07 20:27:45
【问题描述】:

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

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

提前致谢。

【问题讨论】:

    标签: iphone ios objective-c xcode ipad


    【解决方案1】:

    试试看……

    您可以使用两种方法来做到这一点:
    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 中你只需要传递源名称和目的地名称

    希望我能帮上忙……

    【讨论】:

    • @aLFaRSi :是的,您需要使用第二个选项,只需使用 google api 并根据您的选择解析响应并设置数据。
    • 请告诉我怎么做? :)
    • 这很复杂,但您可以通过解析响应来完成。
    • 谢谢你的帮助,这个对我帮助很大:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-18
    相关资源
    最近更新 更多