การเดินทางแบบออนดีมานด์คืออะไร
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เอกสารประกอบในส่วนนี้แสดงวิธีสร้างและจัดการการเดินทางโดยใช้บริการการเดินทางแบบออนดีมานด์ของ Google Maps Mobility โดยจะถือว่าคุณคุ้นเคยกับสิ่งต่อไปนี้
TripService
ที่คุณจะใช้พร้อมใช้งานสำหรับ gRPC และ REST
เพื่อความสะดวก การอ้างอิงฟิลด์จะเป็นไปตามรูปแบบ gRPC
ใน Fleet Engine สำหรับบริการออนดีมานด์ การเดินทางคือการเดินทางประเภทหนึ่งที่จำลอง
การดำเนินการตามคำขอการนำส่งอาหารหรือคำขอเรียกรถจากผู้บริโภค การเดินทาง
มีสถานะที่คุณรายงานไปยัง Fleet Engine เมื่อการเดินทางเปลี่ยนแปลงไป เช่น
NEW
, ENROUTE_TO_PICKUP
และอื่นๆ สถานะการเดินทางสอดคล้องกับจุดอ้างอิงที่ระบุตำแหน่งทางภูมิศาสตร์
ซึ่งกำหนดให้กับยานพาหนะ และ Fleet Engine จะแก้ไขจุดอ้างอิงของยานพาหนะเหล่านี้
เมื่อคุณอัปเดตการเดินทางแต่ละครั้ง ดูข้อมูลเพิ่มเติมเกี่ยวกับการเดินทางและความสัมพันธ์กับการเดินทางกับยานพาหนะได้ที่การเดินทางตามคำขอในข้อมูลสำคัญของ Fleet Engine
อายุการใช้งานของการเดินทาง
หากต้องการติดตามการเดินทางแต่ละครั้งใน Fleet Engine คุณต้องสร้างเอนทิตี Trip
ก่อน ดูข้อมูลอ้างอิงได้ที่ gRPC หรือ REST
ตารางต่อไปนี้อธิบายตัวอย่างโฟลว์การเดินทางแบบครบวงจรที่สร้างขึ้นใน
ระบบของคุณและขั้นตอนวงจรการใช้งานใน Fleet Engine โดยจะถือว่าคุณได้ตั้งค่า
Fleet Engine และมีรถที่จะกำหนดให้กับการเดินทาง พร้อมเปิดใช้การอัปเดตตำแหน่ง
ในแอปคนขับแล้ว ดูDriver SDK: การเดินทางแบบออนดีมานด์
1 |
รับคำขอจอง |
ก่อนที่การเดินทางของ Fleet Engine จะเริ่มขึ้น ระบบการจองของคุณจะได้รับคำขอการเดินทางหรือการนำส่งจากผู้บริโภคผ่านแอปหรือระบบการจองอื่นๆ ก่อน
จากนั้นระบบจะสร้างเอนทิตีการเดินทางโดยใช้
CreateTrip พร้อมฟิลด์ที่จำเป็น เช่น สถานที่รับ
นอกจากนี้ ยังตั้งค่าช่องอื่นๆ ได้ในตอนนี้ เช่น ผู้โดยสารและ
สถานที่ส่ง หรือรอจนกว่าจะมีการกำหนดรถ ดูหัวข้อ
สร้างการเดินทางแบบมีจุดหมายเดียว |
2 |
มอบหมายยานพาหนะ |
คุณจะกำหนดรถให้กับการเดินทางโดยตรงภายในระบบ
และรายงานการกำหนดให้ Fleet Engine หรือจะใช้บริการค้นหารถ
เพื่อค้นหารถ โดยกรองตามทั้งการเดินทางและแอตทริบิวต์ของรถ
เพื่อค้นหารถที่ดีที่สุดสำหรับการเดินทางก็ได้ ยานพาหนะออนไลน์
ที่อยู่ภายในรัศมีการค้นหาจะแจ้งให้ทราบถึงระยะใกล้ผ่าน
การอัปเดตตำแหน่งที่ได้รับจาก Driver SDK
เมื่อ SearchVehicle แสดงยานพาหนะที่ตรงกับการเดินทางของคุณ ระบบจะเรียกใช้ปลายทาง UpdateTrip เพื่อรายงานรหัสยานพาหนะที่คุณกำหนดให้กับการเดินทาง NEW
|
3 |
อัปเดตการเดินทาง |
เมื่อคนขับยอมรับการเดินทางและเริ่มนำทางไปยัง
จุดรับ ระบบจะอัปเดตสถานะการเดินทางจาก NEW
เป็น ENROUTE_TO_PICKUP คุณจะยังคงสำรวจตำแหน่งของยานพาหนะตลอดการเดินทาง ไม่ว่าจะผ่านการเชื่อมต่อโดยตรงจากแอปไปยังแบ็กเอนด์ หรือโดยการสำรวจ Fleet Engine ซึ่งจะได้รับสตรีมการอัปเดตตำแหน่งของยานพาหนะอย่างต่อเนื่องจาก Driver SDK จากนั้น
ระบบจะรายงานเหตุการณ์สำคัญของการเดินทางแต่ละครั้งไปยัง Fleet Engine ซึ่งจะอัปเดต
รายการจุดแวะพักของยานพาหนะตามนั้น
|
4 |
แชร์เส้นทางกับผู้บริโภค |
Fleet Engine จะทำให้รายละเอียดการเดินทางและตำแหน่งของยานพาหนะพร้อมใช้งานใน
Consumer SDK ซึ่งใช้ Listener เพื่อรับการอัปเดตการเดินทางและแสดงการอัปเดต
ในแอปสำหรับผู้บริโภค Fleet Engine จะอัปเดตเวลาถึงโดยประมาณ ระยะทางที่เหลือ
เส้นทาง และจุดแวะพักที่เหลือของยานพาหนะโดยอัตโนมัติ ดูข้อมูลเพิ่มเติมได้ที่แชร์การเดินทางสำหรับการเดินทางแบบออนดีมานด์ |
5 |
การเดินทางเสร็จสมบูรณ์ |
เมื่อยานพาหนะถึงจุดพักรถปลายทางของการเดินทางและคนขับระบุว่าการเดินทางสำเร็จ ระบบจะตั้งค่าTripStatus เป็นCOMPLETE ใน Fleet Engine โปรดทราบว่าเอนทิตีการเดินทางจะยังคงใช้งานได้ภายใน Fleet Engine เป็นเวลา 7 วันไม่ว่าสถานะจะเป็นอย่างไร จากนั้นระบบจะนำเอนทิตีออก |
ลำดับการเดินทาง
แผนภาพต่อไปนี้แสดงมุมมองที่ละเอียดยิ่งขึ้นของโฟลว์นี้

ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 2025-08-31 UTC"],[[["\u003cp\u003eThis documentation provides a comprehensive guide on utilizing the Google Maps Mobility on-demand trips service for managing and tracking trips.\u003c/p\u003e\n"],["\u003cp\u003eYou should have a foundational understanding of Fleet Engine, Vehicle Basics, and Trip Basics for on-demand services.\u003c/p\u003e\n"],["\u003cp\u003eFleet Engine's \u003ccode\u003eTripService\u003c/code\u003e enables the creation, assignment, updating, and completion of trips through gRPC or REST.\u003c/p\u003e\n"],["\u003cp\u003eTrips represent journeys fulfilling consumer requests, evolving through various statuses like \u003ccode\u003eNEW\u003c/code\u003e, \u003ccode\u003eENROUTE_TO_PICKUP\u003c/code\u003e, and \u003ccode\u003eCOMPLETE\u003c/code\u003e, influencing vehicle waypoints.\u003c/p\u003e\n"],["\u003cp\u003eThe trip lifecycle includes booking, vehicle assignment, status updates, consumer journey sharing, and completion, all managed through Fleet Engine interactions.\u003c/p\u003e\n"]]],[],null,["The documentation in this section shows how to create and work with trips using\nthe Google Maps Mobility on-demand trips service. It assumes familiarity with\nthe following:\n\n- **Fleet Engine** : You should be familiar with Fleet Engine implementation details, request mechanisms, and security. For that, see [What is the Fleet\n Engine service?](/maps/documentation/mobility/fleet-engine/essentials) and the security topics in [Set up Fleet Engine](/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet).\n- **Vehicles basics** for on-demand services. See [Introduction to vehicles](/maps/documentation/mobility/fleet-engine/essentials/vehicles-intro).\n- **Trip basics** for on-demand services. See [On-demand trips](/maps/documentation/mobility/fleet-engine/essentials/trip-intro).\n\nThe `TripService` that you'll use is available for [gRPC](/maps/documentation/mobility/fleet-engine/reference/trips/rpc/maps.fleetengine.v1#tripservice) and [REST](/maps/documentation/mobility/fleet-engine/reference/trips/rest/v1/providers.trips).\nFor simplicity sake, field references follow the gRPC convention.\n\nIn Fleet Engine for on-demand services, a trip is a type of journey that models\nthe fulfillment of a food delivery or ride request from your consumers. A trip\nhas a status that you report to Fleet Engine as the journey evolves, such as\n`NEW`, `ENROUTE_TO_PICKUP`, and more. The trip status corresponds to geo-located\nwaypoints assigned to the vehicle, and Fleet Engine modifies these vehicle\nwaypoints with each trip update you make. See [On demand trips](/maps/documentation/mobility/fleet-engine/essentials/trip-intro) in **Fleet\nEngine essentials** for more about trips and their relationship to vehicles.\n\nLife of a trip\n\nIn order to track each trip in Fleet Engine, you must first create a `Trip`\nentity. See either [gRPC](/maps/documentation/mobility/fleet-engine/reference/trips/rpc/maps.fleetengine.v1#maps.fleetengine.v1.Trip) or [REST](/maps/documentation/mobility/fleet-engine/reference/trips/rest/v1/providers.trips) for reference.\n\nThe following table describes an example end-to-end flow of a trip created in\nyour system and its lifecycle stages in Fleet Engine. It assumes you have set up\nFleet Engine and have a vehicle to assign to the trip, with location updates\nenabled in the driver app. See [Driver SDK: On-demand trips](/maps/documentation/mobility/driver-sdk/on-demand).\n\n|---|----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1 | **Receive booking request.** | Before a Fleet Engine trip begins, your booking system first receives a request for a ride or delivery from a consumer through your app or other booking system. Your system then creates the trip entity using `CreateTrip` with required fields, such as the pickup location. It can also set other fields at this point, such passengers and dropoff location, or wait until it assigns a vehicle. See [Create a single-destination trip](/maps/documentation/mobility/fleet-engine/journeys/trips/create-trip). |\n| 2 | **Assign vehicle.** | You can either assign vehicles to trips directly within your system and report the assignment to Fleet Engine, or you can use the [Search Vehicle](/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-search-vehicle) service to search for vehicles, filtering by both trip and vehicle attributes to find the best vehicle to complete the journey. Any online vehicle within your search radius makes their proximity known through location updates provided by the Driver SDK. Once `SearchVehicle` returns a vehicle that you match to a trip, your system calls the `UpdateTrip` endpoint to report the vehicle ID you assigned to the `NEW` trip. |\n| 3 | **Update trip.** | Once the driver accepts the trip and begins navigating to the pickup location, your system updates the trip status from `NEW` to `ENROUTE_TO_PICKUP`. You continue to poll the vehicle location throughout the journey, either through a direct connection from the app to your backend, or by polling Fleet Engine, which receives an ongoing stream of vehicle location updates from the Driver SDK. Your system then reports each journey milestone to Fleet Engine, which updates the vehicle's waypoint list accordingly. |\n| 4 | **Share journey with consumer.** | Fleet Engine makes trip details and vehicle location available to the Consumer SDK, which uses a listener to receive trip updates and display them in the consumer app. Fleet Engine automatically updates ETA, remaining distance, routes, and remaining vehicle waypoints. See [Share journeys for on-demand trips](/maps/documentation/mobility/journey-sharing/on-demand) for more information. |\n| 5 | **Complete trip.** | Once the vehicle reaches the destination waypoint of the trip and your driver indicates a successful trip, your system sets the `TripStatus` to `COMPLETE` in Fleet Engine. Keep in mind that, like vehicles, trip entities remain active within Fleet Engine for 7 days regardless of status, at which point they are removed. |\n\nTrip sequence flow\n\nThe following diagram shows a more detailed view of this flow.\n\nWhat's next\n\n- [Create a single-destination trip](/maps/documentation/mobility/fleet-engine/journeys/trips/create-trip)"]]