Đặt điểm đến cho xe

Phần này trình bày cách thiết lập điểm đến của xe sau máy chủ khớp với một chuyến đi với một chiếc xe.

Trước khi bắt đầu

Phần này yêu cầu bạn phải hoàn thành các bước sau:

Đặt điểm đến trong ứng dụng trình điều khiển

Sau khi ghép nối người tiêu dùng với người lái xe, bạn phải định cấu hình thông tin trong ứng dụng trình điều khiển bằng cách thực hiện các bước sau:

  1. Truy xuất điểm đến của xe từ bộ sưu tập điểm tham chiếu trong Nhóm Engine, được GetTrip(), UpdateTrip()GetVehicle() trả về.

  2. Đặt đích đến bằng cách gọi phương thức SDK điều hướng dành cho iOS setDestinations().

Các ví dụ sau đây minh hoạ cách thiết lập điểm đến trong trình điều khiển .

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;
                             }];
}