本文档介绍了如何管理应用的航点偏好设置 两种功能:
- 道路一侧路线偏好设置
- 中途停留
设置侧面道路路线偏好设置
默认情况下,Navigation SDK for iOS 会查找前往 航点,但这并不保证 所需的道路一侧,例如拼车出行的道路一侧 顾客正在等候。道路路线选择偏好 功能可以让您确保车辆抵达正确的一侧 。
工作原理
通过设置抵达道路某一侧的偏好 为该经停点创建航点。您可以采用以下两种方式之一指定偏好设置 方法。
更喜欢道路的同一侧
您提供航点的地理坐标,然后设置一个标志,
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 会选择距离 航点 - 该航点的车道方向与 航点所在道路一侧
设置停靠偏好
在某些位置,用户无法安全停止(例如,
高架区域、轮渡、地下以及其他限行区域
访问权限)。如果出现以下情况,停靠功能会将航点重新定位到附近的地点:
位置不适合用户停车。当您设置
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){...}];