本部分介绍了在服务器将行程与车辆匹配后如何设置车辆的目的地。
准备工作
本部分要求您完成以下操作:
在驾驶员应用中设置目的地
将消费者与驾驶员配对后,您必须在驾驶员应用中配置行程的目的地,具体步骤如下:
从车队引擎中的路点集合中检索车辆的目的地,该集合由
GetTrip()
、UpdateTrip()
和GetVehicle()
返回。通过调用 Navigation SDK for iOS 的
setDestinations()
方法设置目的地。
以下示例展示了如何在驱动程序应用中设置目的地。
Swift
private func startNavigation() {
let destinations = [
GMSNavigationWaypoint(
placeID: "ChIJnUYTpNASkFQR_gSty5kyoUk", title: "PCC Natural Market"),
GMSNavigationWaypoint(
placeID: "ChIJJ326ROcSkFQRBfUzOL2DSbo", title: "Marina Park"),
]
mapView.navigator?.setDestinations(destinations, callback: { routeStatus in
guard routeStatus == .OK else {
// Error starting navigation.
return
}
mapView.locationSimulator?.simulateLocationsAlongExistingRoute()
mapView.navigator?.isGuidanceActive = true
mapView.navigator?.sendsBackgroundNotifications = true
mapView.cameraMode = .following
})
}
Objective-C
- (void)startNavigation {
NSArray<GMSNavigationWaypoint *> *destinations =
@[[[GMSNavigationWaypoint alloc] initWithPlaceID:@"ChIJnUYTpNASkFQR_gSty5kyoUk"
title:@"PCC Natural Market"],
[[GMSNavigationWaypoint alloc] initWithPlaceID:@"ChIJJ326ROcSkFQRBfUzOL2DSbo"
title:@"Marina Park"]];
[_mapView.navigator setDestinations:destinations
callback:^(GMSRouteStatus routeStatus) {
if (routeStatus != GMSRouteStatusOK) {
// Error starting navigation.
return;
}
[_mapView.locationSimulator simulateLocationsAlongExistingRoute];
_mapView.navigator.guidanceActive = YES;
_mapView.navigator.sendsBackgroundNotifications = YES;
_mapView.cameraMode = GMSNavigationCameraModeFollowing;
}];
}