这是Valhalla项目的官方客户端(https://github.com/valhalla)。它目前提供了一个在多个点之间拉取航线的的实现,并基于来自TrailBehind公司为他们的GaiaGPS产品所做的(https://www.gaiagps.com/)工作。
我们推荐使用CocoaPods(https://cocoapods.org.cn/)来安装库。它只依赖于Foundation和UIKit。
pod 'OnTheRoad'
这里有一个示例,展示了如何使用On The Road非常简单。请确保阅读(文档),以查看所有您在发起请求时可以定制的属性。
多个点之间的路线
OTRRoutingController *router = [[OTRRoutingController alloc] init];
OTRRoutingPoint *loc1 = [OTRRoutingPoint pointWithCoordinate:OTRGeoPointMake(40.74433, -73.9903) type:OTRRoutingPointTypeBreak];
OTRRoutingPoint *loc2 = [OTRRoutingPoint pointWithCoordinate:OTRGeoPointMake(40.734807, -73.984770) type:OTRRoutingPointTypeThrough];
OTRRoutingPoint *loc3 = [OTRRoutingPoint pointWithCoordinate:OTRGeoPointMake(40.732172, -73.998674) type:OTRRoutingPointTypeThrough];
OTRRoutingPoint *loc4 = [OTRRoutingPoint pointWithCoordinate:OTRGeoPointMake(40.741050, -73.996142) type:OTRRoutingPointTypeBreak];
NSArray *locations = [NSArray arrayWithObjects:loc1, loc2, loc3, loc4, nil];
NSDictionary *costingOptions = [NSDictionary dictionaryWithObjectsAndKeys:@"use_ferry", @"0", nil];
NSDictionary *directionsOptions = [NSDictionary dictionaryWithObjectsAndKeys:@"units", @"miles", @"language", @"fr-FR", nil];
[router requestRouteWithLocations:locations costingModel:OTRRoutingCostingModelAuto costingOption:costingOptions directionsOptions:directionsOptions callback:^(OTRRoutingResult * _Nullable result, id _Nullable invalidationToken, NSError * _Nullable error) {
if (result) {
// plot maneuvers on map
}
}];
我们欢迎使用Github Issue tracker报告问题。但是,在报告错误之前,请先查看当前开放的问题,以避免问题跟踪器频繁变动。
请发送您想要的所有PR!我们强制执行良好的测试覆盖率,所以在提交拉取请求之前,请确保所有新的代码都是可覆盖的,并且在本地测试通过。