本文档介绍了如何使用以下两个功能管理应用的航点偏好设置:
- 道路一侧路线偏好设置
- 中途停留
设置侧面道路路线偏好设置
默认情况下,iOS 版 Navigation SDK 会查找前往航点的最快路线,但这并不能保证用户一定会到达所需的道路一侧,例如拼车司机的客户所等待的道路一侧。借助道路侧面路线偏好设置功能,您可以确保车辆到达正确的道路一侧。
运作方式
在为该经停点创建航点时,您可以设置到达道路某一侧的偏好设置。您可以通过以下两种方式之一指定偏好设置。
更喜欢道路的同一侧
您提供航点的地理坐标,然后设置 preferSameSideOfRoad
标志,指示您希望与航点抵达同一道路的一侧,即贴靠到最近的人行道。
(nullable instancetype)initWithLocation:(CLLocationCoordinate2D)location
title:(NSString *)title
preferSameSideOfRoad:(BOOL)preferSameSideOfRoad;
首选片段标题
您提供航点的地理坐标,然后提供到达航向 preferredSegmentHeading
,该航向与目的地道路所在道路一侧的车流方向相匹配。
(nullable instancetype)initWithLocation:(CLLocationCoordinate2D)location
title:(NSString *)title
preferredSegmentHeading:(int32_t)preferredSegmentHeading;
Navigation SDK 会选择距离航点最近的路段,该路段的车道方向与航点所在道路的一侧对齐(在 +/- 55 度范围内)。
设置停靠偏好
在某些位置,用户无法安全停靠(例如,高架区域、轮渡、地下位置和其他限制通行的区域)。如果航点的位置不适合用户经停,停靠功能会将航点重新定位到附近的地点。将 vehicleStopover
设置为 YES
后,在计算路线时自动重新定位航点(如果有备选位置)。
运作方式
您可以在为经停点创建航点时设置停靠点偏好设置。为此,请设置在 GMSNavigationMutableWaypoint
上停留的偏好设置,如以下示例所示:
Swift
let location = CLLocationCoordinate2D(latitude: 47.67, longitude: -122.20) let waypoint = GMSNavigationMutableWaypoint(location: location, title: "waypoint from location")! waypoint.vehicleStopover = true mapView.navigator?.setDestinations([waypoint], routingOptions: routingOptions, callback: {...})
Objective-C
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(47.67, -122.20); GMSNavigationMutableWaypoint *waypoint = [[GMSNavigationMutableWaypoint alloc] initWithLocation:location title:@"waypoint from location"]; waypoint.vehicleStopover = YES; [_mapView.navigator setDestinations:@[waypoint1] routingOptions:routingOptions callback:^(GMSRouteStatus routeStatus){...}];