تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
لإنشاء مركبة في Fleet Engine للرحلات عند الطلب، استخدِم نقطة النهاية CreateVehicle مع CreateVehicleRequest. يتطلّب نقطة النهاية هذه حسابًا لديه دور مشرف Fleet Engine عند الطلب.
حقول مركبات الرحلات عند الطلب
عند إنشاء مركبات للرحلات عند الطلب، يجب ضبط الحقول المطلوبة. يجب أيضًا أن تكون على دراية بكيفية تأثير بعض حقول المركبة في وظائف أخرى في Fleet Engine. يمكنك الاطّلاع على تعديل حقول المركبة لمعرفة المزيد.
الحقول المطلوبة للرحلات عند الطلب
vehicle_state: يتم ضبط القيمة التلقائية على "غير معروف"، ولكن يجب ضبطها على ONLINE أو OFFLINE. اطّلِع على معلومات حول ضبط حقل حالة المركبة في تعديل حقول المركبة.
supported_trip_types: القيمة التلقائية هي unknown، ولكن يجب ضبطها على SHARED أو EXCLUSIVE أو كليهما. يمكنك الاطّلاع على أنواع الرحلات في دليل الرحلات عند الطلب
للحصول على التفاصيل.
استبدِل maximum_capacity بعدد الركاب الذين يمكن أن تقلّهم المركبة،
باستثناء السائق (حسب التعريف).
vehicle_type: القيم هي AUTO أو TAXI أو TRUCK أو TWO_WHEELER أو BICYCLE أو PEDESTRIAN. يمكن استخدامها لفلترة المركبات عند البحث عنها. ويؤثّر ذلك أيضًا في حسابات الوقت المقدَّر للوصول والمسار. توفّر Fleet Engine مسارات واحتسابات للرحلات تتوافق مع وسيلة النقل استنادًا إلى مجموعات أنواع المركبات التالية:
AUTO أو TAXI أو TRUCK: على سبيل المثال، الطرق السريعة
TWO_WHEELER: على سبيل المثال، لن تعرض هذه الطريقة مسارات لا يُسمح فيها باستخدام المركبات ذات العجلتين.
BICYCLE: على سبيل المثال، مسارات الدراجات
PEDESTRIAN: على سبيل المثال، الجسور والممرات المخصّصة للمشاة فقط
الحقول الأخرى
للاطّلاع على الحقول الأخرى التي يمكنك ضبطها عند إنشاء مركبة، راجِع تعديل حقول المركبة.
مثال على إنشاء مركبة
القيمة التي يتم إرجاعها من CreateVehicle هي العنصر Vehicle الذي تم إنشاؤه.
Java
staticfinalStringPROJECT_ID="project-id";VehicleServiceBlockingStubvehicleService=VehicleService.newBlockingStub(channel);Stringparent="providers/"+PROJECT_ID;Vehiclevehicle=Vehicle.newBuilder().setVehicleState(VehicleState.OFFLINE)// Initial state.addSupportedTripTypes(TripType.EXCLUSIVE).setMaximumCapacity(4).setVehicleType(VehicleType.newBuilder().setCategory(VehicleType.Category.AUTO)).addAttributes(VehicleAttribute.newBuilder().setKey("on_trip").setValue("false"))// Opaque to the Fleet Engine// Add .setBackToBackEnabled(true) to make this vehicle eligible for trip// matching while even if it is on a trip. By default this is disabled..build();CreateVehicleRequestcreateVehicleRequest=CreateVehicleRequest.newBuilder()// no need for the header.setParent(parent).setVehicleId("vid-8241890")// Vehicle ID assigned by Rideshare or Delivery Provider.setVehicle(vehicle)// Initial state.build();// In this case, the Vehicle is being created in the OFFLINE state and// no initial position is being provided. When the Driver App checks// in with the Rideshare or Delivery Provider, the state can be set to ONLINE and// the Driver App will update the Vehicle Location.try{VehiclecreatedVehicle=vehicleService.createVehicle(createVehicleRequest);}catch(StatusRuntimeExceptione){Statuss=e.getStatus();switch(s.getCode()){caseALREADY_EXISTS:break;casePERMISSION_DENIED:break;}return;}// If no Exception, Vehicle created successfully.
تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eTo create on-demand vehicles in Fleet Engine, use the \u003ccode\u003eCreateVehicle\u003c/code\u003e endpoint, requiring the \u003cem\u003eFleet Engine On-demand Admin\u003c/em\u003e role.\u003c/p\u003e\n"],["\u003cp\u003eEssential fields for vehicle creation include \u003ccode\u003evehicle_state\u003c/code\u003e, \u003ccode\u003esupported_trip_types\u003c/code\u003e, \u003ccode\u003emaximum_capacity\u003c/code\u003e, and \u003ccode\u003evehicle_type\u003c/code\u003e, which influence trip matching and routing.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided Java and REST examples for detailed code implementation of vehicle creation requests.\u003c/p\u003e\n"],["\u003cp\u003eAfter vehicle creation, manage and update vehicle attributes using the \u003ccode\u003eUpdateVehicle\u003c/code\u003e endpoint as needed.\u003c/p\u003e\n"]]],[],null,["# Create a vehicle for on-demand trips\n\n| **Note:** **Before constructing a vehicle request** , read the requirements under [Vehicle requests](/maps/documentation/mobility/fleet-engine/essentials/vehicles#vehicle_requests) in the Introduction.\n\nTo create a vehicle in Fleet Engine for on-demand trips, use the `CreateVehicle`\nendpoint with the `CreateVehicleRequest`. This endpoint requires an account with\nthe *Fleet Engine On-demand Admin* role.\n\nFields for on-demand trip vehicles\n----------------------------------\n\nWhen creating vehicles for on-demand trips, you must set required fields. You\nshould also be familiar with how certain vehicle fields impact other\nfunctionality in Fleet Engine. See [Update vehicle fields](/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-vehicle-fields) for that.\n\n### Required fields for on-demand trips\n\n- **`vehicle_state`** : Defaults to unknown, but should be set to ONLINE or OFFLINE. See information about setting the vehicle state field in [Update\n vehicle fields](/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-vehicle-fields).\n- **`supported_trip_types`** : Defaults to unknown, but should be set to SHARED, EXCLUSIVE, or both. See [Trip types](/maps/documentation/mobility/fleet-engine/essentials/trip-intro#trip_types) in the **On-demand trips** guide for details.\n- **`maximum_capacity`**: The number of passengers the vehicle can carry, which excludes the driver (by definition).\n- **`vehicle_type`** : Values are `AUTO`, `TAXI`, `TRUCK`, `TWO_WHEELER`, `BICYCLE`, or `PEDESTRIAN`. Can be used to filter vehicles for vehicle searches. This also influences ETA and route calculations. Fleet Engine provides routes and travel calculations that corresponds to the mode of travel based on the following vehicle type groups:\n - `AUTO`, `TAXI` or `TRUCK`: for example highways.\n - `TWO_WHEELER`: for example won't return routes where 2-wheelers aren't allowed.\n - `BICYCLE`: for example, bicycle paths.\n - `PEDESTRIAN`: for example pedestrian-only bridges and walkways.\n\n### Other fields\n\nFor other fields that you can set when creating a vehicle, see [Update vehicle\nfields](/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-vehicle-fields).\n\nVehicle creation example\n------------------------\n\nThe value returned from `CreateVehicle` is the created `Vehicle` entity. \n\n### Java\n\n static final String PROJECT_ID = \"\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e\";\n\n VehicleServiceBlockingStub vehicleService =\n VehicleService.newBlockingStub(channel);\n\n String parent = \"providers/\" + PROJECT_ID;\n Vehicle vehicle = Vehicle.newBuilder()\n .setVehicleState(VehicleState.OFFLINE) // Initial state\n .addSupportedTripTypes(TripType.EXCLUSIVE)\n .setMaximumCapacity(4)\n .setVehicleType(VehicleType.newBuilder().setCategory(VehicleType.Category.AUTO))\n .addAttributes(VehicleAttribute.newBuilder()\n .setKey(\"on_trip\").setValue(\"false\")) // Opaque to the Fleet Engine\n // Add .setBackToBackEnabled(true) to make this vehicle eligible for trip\n // matching while even if it is on a trip. By default this is disabled.\n .build();\n\n CreateVehicleRequest createVehicleRequest =\n CreateVehicleRequest.newBuilder() // no need for the header\n .setParent(parent)\n .setVehicleId(\"\u003cvar translate=\"no\"\u003evid-8241890\u003c/var\u003e\") // Vehicle ID assigned by Rideshare or Delivery Provider\n .setVehicle(vehicle) // Initial state\n .build();\n\n // In this case, the Vehicle is being created in the OFFLINE state and\n // no initial position is being provided. When the Driver App checks\n // in with the Rideshare or Delivery Provider, the state can be set to ONLINE and\n // the Driver App will update the Vehicle Location.\n\n try {\n Vehicle createdVehicle =\n vehicleService.createVehicle(createVehicleRequest);\n } catch (StatusRuntimeException e) {\n Status s = e.getStatus();\n switch (s.getCode()) {\n case ALREADY_EXISTS:\n break;\n case PERMISSION_DENIED:\n break;\n }\n return;\n }\n // If no Exception, Vehicle created successfully.\n\n### REST\n\n curl -X POST \\\n \"https://fleetengine.googleapis.com/v1/providers/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/vehicles?vehicleId=\u003cvar translate=\"no\"\u003evid-8241890\u003c/var\u003e\" \\\n -H \"Authorization: Bearer $JWT\" \\\n -H \"Content-Type: application/json\" \\\n --data-binary @- \u003c\u003c EOM\n {\n \"vehicleState\": \"OFFLINE\",\n \"supportedTripTypes\": [\"EXCLUSIVE\"],\n \"maximumCapacity\": 4,\n \"vehicleType\": {\"category\": \"AUTO\"},\n \"attributes\": [{\"key\": \"on_trip\", \"value\": \"false\"}]\n }\n EOM\n\nSee [providers.vehicles.create](/maps/documentation/mobility/fleet-engine/reference/trips/rest/v1/providers.vehicles/create) reference.\n\nWhat's next\n-----------\n\n- [Update vehicle fields](/maps/documentation/mobility/fleet-engine/essentials/vehicles/on-demand-vehicle-fields)"]]