בקטע הזה מוסבר איך להגדיר את יעד הנסיעה של הרכב אחרי שהשרת מתאים בין נסיעה לרכב.
לפני שמתחילים
כדי להשלים את החלק הזה, צריך לבצע את הפעולות הבאות:
הגדרת היעד באפליקציית הנהג
אחרי שמתאימים בין לקוח לנהג, צריך להגדיר את יעד הנסיעה באפליקציה לנהגים. כדי לעשות את זה:
אחזור היעד של הרכב מאוסף נקודות הציון שלו ב-Fleet Engine, שמוחזר על ידי
GetTrip(),UpdateTrip()ו-GetVehicle().מגדירים את היעד באמצעות קריאה ל-method של Navigation SDK ל-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;
}];
}