本文档介绍了如何使用两项功能来管理应用的航点偏好设置:
- 道路一侧路线偏好设置
- 中途停留
设置道路路线偏好设置的一侧
默认情况下,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 会选择距离航点最近的路段,该路段的车道方向与航点所在的道路一侧对齐(在 +/- 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){...}];