In diesem Abschnitt wird beschrieben, wie Sie das Ziel des Fahrzeugs festlegen, nachdem Ihr Server eine Fahrt einem Fahrzeug zugeordnet hat.
Hinweis
Für diesen Abschnitt müssen Sie Folgendes erledigt haben:
Ziel in der Fahrer-App festlegen
Nachdem Sie einen Nutzer mit einem Fahrer gekoppelt haben, müssen Sie das Ziel der Fahrt in der Fahrer-App konfigurieren. Gehen Sie dazu so vor:
Rufen Sie das Ziel des Fahrzeugs aus der Sammlung von Wegpunkten in Fleet Engine ab, die von
GetTrip()
,UpdateTrip()
undGetVehicle()
zurückgegeben wird.Legen Sie das Ziel fest, indem Sie die Navigation SDK for iOS-Methode
setDestinations()
aufrufen.
Die folgenden Beispiele zeigen, wie Sie das Ziel in der Fahrer-App festlegen.
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;
}];
}