এই বিভাগটি নথিভুক্ত করে যে কীভাবে গাড়ির গন্তব্য নির্ধারণ করতে হয় আপনার সার্ভার গাড়িতে ভ্রমণের সাথে মিলে যায়।
আপনি শুরু করার আগে
এই বিভাগে আপনাকে নিম্নলিখিতগুলি সম্পূর্ণ করতে হবে:
ড্রাইভার অ্যাপে গন্তব্য সেট করুন
আপনি একজন ভোক্তাকে ড্রাইভারের সাথে যুক্ত করার পরে, আপনাকে নিম্নলিখিত পদক্ষেপগুলি সম্পাদন করে ড্রাইভার অ্যাপে ভ্রমণের গন্তব্য কনফিগার করতে হবে:
- ফ্লিট ইঞ্জিনের ওয়েপয়েন্ট সংগ্রহ থেকে গাড়ির গন্তব্য পুনরুদ্ধার করুন, যা - GetTrip(),- UpdateTrip()এবং- GetVehicle()দ্বারা ফেরত দেওয়া হয়।
- Android পদ্ধতি - setDestination()এর জন্য নেভিগেশন SDK-এ কল করে গন্তব্য সেট করুন।
নিম্নলিখিত উদাহরণগুলি দেখায় কিভাবে ড্রাইভার অ্যাপে গন্তব্য সেট করতে হয়।
জাভা
private void navigateToLocation(LatLng locationLatLng, RoutingOptions routingOptions) {
  Waypoint destination = Waypoint.newBuilder().setLocation(locationLatLng).build();
  // Create a future to await the result of the asynchronous navigator task.
  ListenableResultFuture<Navigator.RouteStatus> pendingRoute =
      mNavigator.setDestination(destination, travelMode);
  // Define the action to perform when the SDK has determined the route.
  pendingRoute.setOnResultListener(
      new ListenableResultFuture.OnResultListener<Navigator.RouteStatus>() {
        @Override
        public void onResult(Navigator.RouteStatus code) {
          switch (code) {
            case OK:
              // Hide the toolbar to maximize the navigation UI.
              if (getActionBar() != null) {
                getActionBar().hide();
              }
              // Enable voice audio guidance (through the device speaker).
              mNavigator.setAudioGuidance(
                  Navigator.AudioGuidance.VOICE_ALERTS_AND_GUIDANCE);
              // Simulate vehicle progress along the route for demo/debug builds.
              if (BuildConfig.DEBUG) {
                mNavigator.getSimulator().simulateLocationsAlongExistingRoute(
                    new SimulationOptions().speedMultiplier(5));
              }
              // Start turn-by-turn guidance along the current route.
              mNavigator.startGuidance();
              break;
            // Handle error conditions returned by the navigator.
            case NO_ROUTE_FOUND:
              displayMessage("Error starting navigation: No route found.");
              break;
            case NETWORK_ERROR:
              displayMessage("Error starting navigation: Network error.");
              break;
            case ROUTE_CANCELED:
              displayMessage("Error starting navigation: Route canceled.");
              break;
            default:
              displayMessage("Error starting navigation: "
                  + String.valueOf(code));
          }
        }
      });
}
কোটলিন
private fun navigateToLocation(locationLatLng: LatLng, travelMode: RoutingOptions) {
  val destination = Waypoint.newBuilder().setLocation(locationLatLng).build()
  // Create a future to await the result of the asynchronous navigator task.
  val pendingRoute = mNavigator.setDestination(destination, travelMode)
  // Define the action to perform when the SDK has determined the route.
  pendingRoute.setOnResultListener(
    object : ListenableResultFuture.OnResultListener<Navigator.RouteStatus>() {
      override fun onResult(code: Navigator.RouteStatus) {
        when (code) {
          Navigator.RouteStatus.OK -> {
            // Hide the toolbar to maximize the navigation UI.
            getActionBar()?.hide()
            // Enable voice audio guidance (through the device speaker).
            mNavigator.setAudioGuidance(Navigator.AudioGuidance.VOICE_ALERTS_AND_GUIDANCE)
            // Simulate vehicle progress along the route for demo/debug builds.
            if (BuildConfig.DEBUG) {
              mNavigator
                .getSimulator()
                .simulateLocationsAlongExistingRoute(SimulationOptions().speedMultiplier(5))
            }
            // Start turn-by-turn guidance along the current route.
            mNavigator.startGuidance()
          }
          Navigator.RouteStatus.NO_ROUTE_FOUND -> {
            displayMessage("Error starting navigation: No route found.")
          }
          Navigator.RouteStatus.NETWORK_ERROR -> {
            displayMessage("Error starting navigation: Network error.")
          }
          Navigator.RouteStatus.ROUTE_CANCELED -> {
            displayMessage("Error starting navigation: Route canceled.")
          }
          else -> {
            displayMessage("Error starting navigation: ${code.name}")
          }
        }
      }
    }
  )
}