تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
المطوّرون في المنطقة الاقتصادية الأوروبية
عند احتساب مسار أو مصفوفة مسارات، قد تحتاج إلى أخذ رسوم العبور في الاعتبار.
في مدن محدّدة، يمكنك احتساب رسوم المرور المقدّرة على طريق معيّن بالعملة المناسبة.
للاطّلاع على قائمة بالمواقع الجغرافية التي تتوفر فيها خدمة دفع رسوم المرور، راجِع مرجع TollPass.
كيفية احتساب رسوم المرور
تحسب واجهة Routes API رسوم العبور المقدّرة، مع الأخذ في الاعتبار أي خصومات أو بطاقات متاحة للسائق أو المركبة، بالإضافة إلى طرق الدفع الأكثر ملاءمة.
إذا لم يتوفّر سعر رسوم عبور لمسار معيّن، تشير واجهة برمجة التطبيقات Routes API إلى توفّر رسوم عبور غير معروفة.
للحصول على تقديرات دقيقة لرسوم المرور، احرص على تضمين المعلومات التالية في طلبك:
نوع الانبعاثات للمركبة المستخدَمة في المسار
(VehicleEmissionType).
في حال عدم توفير نوع الانبعاثات، يتم عرض رسوم المرور لمركبة تعمل بالبنزين.
جميع بطاقات المرور التي يملكها السائق والمركبة باستخدام
(TollPass). تستخدم واجهة برمجة التطبيقات بطاقات المرور لتحديد رسوم المرور بدقة، وتعرض الأسعار النقدية عندما لا تكون بطاقات المرور في الطلب محلية للمسار.
تحديد خيار "تجنُّب رسوم العبور"، إذا لزم الأمر إذا كنت تريد تجنُّب الطرق التي تتضمّن رسوم عبور حيثما أمكن، أضِف avoidTolls كـ RouteModifier.
احتساب رسوم العبور باستخدام بطاقة عبور
لاحتساب رسوم المرور باستخدام بطاقة دفع رسوم المرور، عليك تحديد أي بطاقات دفع رسوم مرور كجزء من الطلب. بعد ذلك، تعرض واجهة برمجة التطبيقات أسعار التذاكر.
في حال تحديد بطاقة مرور غير صالحة، سيتم تجاهل البطاقة.
إذا حدّدت بطاقات مرور متعدّدة كصفيف، ستحاول واجهة برمجة التطبيقات احتساب سعر المسار لكل بطاقة.
قد تختلف طريقة عمل بطاقات المرور على الطرق السريعة حسب المنطقة.
قد تكون الأسعار أقل عند استخدام بطاقة عبور: في بعض المناطق، يدفع السائق أو صاحب المركبة
الذي يستخدم بطاقة عبور رسوم عبور مختلفة عن الرسوم التي يدفعها السائقون الذين لا يملكون بطاقة.
على سبيل المثال، إذا كان لديك بطاقة مرور
Good To Go!
في سياتل، واشنطن، الولايات المتحدة، ستدفع رسوم عبور أقل من الرسوم التي تدفعها إذا لم يكن لديك بطاقة.
قد تتطلّب بعض الطرق بطاقة مرور: في بعض المناطق، مثل إندونيسيا، تتطلّب بعض الطرق بطاقة مرور. إذا لم تحدّد بطاقة مرور على الطرق السريعة لطريق يتطلّب ذلك، لن تعرض واجهة برمجة التطبيقات سعر المرور على الطرق السريعة.
حساب رسوم الطريق على مسار
يستخدم المثال التالي طريقة
computeRoutes
لعرض معلومات حول رسوم المرور مع سعر تقديري عند استخدام بطاقة دفع رسوم المرور. في هذا المثال، عليك اتّباع الخطوات التالية:
اضبط حقل مصفوفة extraComputations على TOLLS لتفعيل احتساب معلومات رسوم المرور.
حدِّد نوع المركبة ونوع بطاقة المرور عبر الطرق السريعة باستخدام الحقل routeModifiers في الطلب. يستند سعر رسوم العبور الذي يتم عرضه إلى الأسعار التي يستخدمها نوع المركبة وبطاقة العبور المحدّدين. في حال تحديد أكثر من تذكرة واحدة، سيتم عرض السعر الأقل.
استخدِم قناع حقل الردّ لضبط طريقة عرض معلومات الرسوم في الردّ. في هذا المثال، تضمّن الطلب السمات التالية في قناع حقول الردّ:
حقل routes.travelAdvisory.tollInfo لعرض معلومات المسار بأكمله.
routes.legs.travelAdvisory.tollInfo لعرض معلومات
عن كل جزء من الرحلة.
تحتوي الاستجابة على معلومات حول رسوم المرور في عنصر TollInfo (REST) أو TollInfo (gRPC). في هذا المثال، يتم عرض معلومات الرسوم على الطريق للمسار بأكمله ولكل جزء من المسار.
تاريخ التعديل الأخير: 2025-08-10 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-10 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThe Routes API can calculate estimated toll fees for routes in select cities, taking into account toll discounts, passes, and payment methods.\u003c/p\u003e\n"],["\u003cp\u003eTo get accurate toll estimates, specify the vehicle's emission type, any applicable toll passes, and whether to avoid tolls using RouteModifiers.\u003c/p\u003e\n"],["\u003cp\u003eToll pass usage can result in lower rates or may be required for certain roads, with the API attempting to calculate prices based on provided passes.\u003c/p\u003e\n"],["\u003cp\u003eRequests calculating tolls are billed at a higher rate, and the returned \u003ccode\u003eestimatedPrice\u003c/code\u003e applies to non-commercial vehicles, potentially differing for commercial ones.\u003c/p\u003e\n"],["\u003cp\u003eToll information can be obtained by setting \u003ccode\u003eextraComputations\u003c/code\u003e to \u003ccode\u003eTOLLS\u003c/code\u003e, specifying vehicle and toll pass details in \u003ccode\u003erouteModifiers\u003c/code\u003e, and using a response field mask to include tollInfo in the output.\u003c/p\u003e\n"]]],["The Routes API can compute estimated toll fees for routes, considering toll discounts and payment methods. Accurate toll calculations require specifying vehicle emission type and applicable toll passes. The API returns cash prices if no passes are specified. Toll passes can offer lower rates or be mandatory in some regions. To get toll information, include \"TOLLS\" in `extraComputations` and specify toll passes in `routeModifiers`. The API then returns the toll prices in the response, which may vary by the requested toll passes.\n"],null,["# Calculate toll fees for a route\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nWhen you are computing a route or a route matrix,\nyou might want to take into consideration any toll fees on the route.\nFor select cities, you can compute the estimated\ntoll fee for a route in the appropriate currency.\n\nTo get tolls for a route matrix, see\n[Calculate tolls fees for a route matrix](/maps/documentation/routes/calculate_toll-rm).\n\nFor the list of supported toll locations, see the reference for\n[TollPass](/maps/documentation/routes/reference/rest/v2/RouteModifiers#tollpass).\n| **Caution:** Requests that calculate toll fees are billed at a higher rate. [Learn more about billing](/maps/documentation/routes/usage-and-billing) for the Routes API.\n\nHow tolls are calculated\n------------------------\n\nThe Routes API calculates the estimated toll fee,\ntaking into consideration any toll price discounts or passes available\nto the driver or vehicle, and the most convenient payment methods.\nIf there is no available toll price for a given route,\nthe Routes API indicates the existence of a toll\nwith an unknown fee.\n| **Note** : The Routes API calculates tolls on a route differently than Google Maps:\n|\n| - The Routes API returns only the toll prices (pass or cash) that would actually be charged for the trip, assuming your request accurately represents what types of passes each driver and/or vehicle has. If you don't specify any toll passes, the API returns the cash prices, which is usually the highest toll.\n| - Google Maps typically returns the cheapest possible price for a vehicle. Users cannot specify which toll passes they have; instead, to see cash tolls, users can disable the **See toll pass prices** option, which is enabled by default.\n\nTo get accurate toll estimates, make sure you include the following information\nin your request:\n\n- **The emission type** of the vehicle used for the route ([`VehicleEmissionType`](/maps/documentation/routes/reference/rest/v2/RouteModifiers#vehicleemissiontype)). If no emission type is provided, the toll for a gasoline-fueled vehicle is returned.\n- **All toll passes the vehicle and driver have** using ([`TollPass`](/maps/documentation/routes/reference/rest/v2/RouteModifiers#tollpass)). The API uses the toll passes to determine accurate toll fees, and returns cash prices when toll passes in the request are not local to the route.\n- **Specify avoid tolls, if needed** . If you want to avoid toll roads where possible, add `avoidTolls` as a `RouteModifier`.\n\n### Calculate tolls using a toll pass\n\nTo calculate tolls using a toll pass, you specify any toll passes as part of\nthe request. The API then returns pass prices.\n\n- If you specify an invalid toll pass, the pass is ignored.\n\n- If specify multiple toll passes as an array, the API attempts to\n calculate the price for the route for each pass.\n\n| **Note:** You can only specify a toll pass for the `DRIVE` and `TWO_WHEELER` travel modes.\n\nThe way toll passes behave can vary by region.\n\n- **Rates may be lower with a toll pass** : In some regions, a driver or vehicle\n with a toll pass pays a different toll than those who don't have a pass.\n For example, if you have a\n [Good To Go!](https://en.wikipedia.org/wiki/Good_to_Go_(toll_collection_system))\n toll pass in Seattle, WA, US, you pay a lower toll than if you don't have a\n pass.\n\n- **Some roads may require a toll pass**: Some regions, such as Indonesia, have\n roads that require a toll pass. If you don't specify a toll pass for a\n route where a toll pass is required, the API does not return a toll price.\n\nCalculate toll fees for a route\n-------------------------------\n\nThe following example uses the\n[`computeRoutes`](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes)\nmethod to return toll information with an estimated\nprice when a toll pass is used. In this example, you:\n\n- Set the `extraComputations` array field to `TOLLS` to enable the calculation\n of toll information.\n\n- Specify the vehicle type and the toll pass type by using the\n `routeModifiers` field of the request. The toll price returned is based on\n the pricing used by the specified vehicle type and pass. If more than one\n pass is specified, the least expensive pricing is returned.\n\n- Use the [response field mask](/maps/documentation/routes/choose_fields) to configure the method to\n return toll information in the response. In this example, the request\n included the following properties in the response field mask:\n\n - `routes.travelAdvisory.tollInfo` field to return information for the\n entire route.\n\n - `routes.legs.travelAdvisory.tollInfo` to return information\n for each leg.\n\n | **Note:** This route contains only one leg.\n\n### Request for toll information\n\n```console\ncurl -X POST -d '{\n \"origin\":{\n \"location\":{\n \"latLng\":{\n \"latitude\":42.340173523716736,\n \"longitude\":-71.05997968330408\n }\n }\n },\n \"destination\":{\n \"location\":{\n \"latLng\":{\n \"latitude\":42.075698891472804,\n \"longitude\": -72.59806562080408\n }\n }\n },\n \"travelMode\": \"DRIVE\",\n \"extraComputations\": \\[\"TOLLS\"\\],\n \"routeModifiers\":{\n \"vehicleInfo\":{\n \"emissionType\": \"GASOLINE\"\n },\n \"tollPasses\": [\n \"US_MA_EZPASSMA\",\n \"US_WA_GOOD_TO_GO\"\n ]\n }\n}' \\\n-H 'Content-Type: application/json' \\\n-H 'X-Goog-Api-Key: \u003cvar translate=\"no\"\u003eYOUR_API_KEY\u003c/var\u003e' \\\n-H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.travelAdvisory.tollInfo,routes.legs.travelAdvisory.tollInfo' \\\n'https://routes.googleapis.com/directions/v2:computeRoutes'\n```\n\n### Response containing toll information\n\nThe response contains information on tolls in a\n[TollInfo](/maps/documentation/routes/reference/rest/v2/TollInfo) (REST) or\n[TollInfo](/maps/documentation/routes/reference/rpc/google.maps.routing.v2#tollinfo) (gRPC) object. In this\nexample, you return toll information for the entire route and for each leg of\nthe route.\n| **Note** : The Routes API provides an `estimatedPrice` that applies to non-commercial vehicles.\n|\n| - Toll prices may be different for commercial vehicles.\n- The `units` and `nanos` are omitted when their value is zero. \n\n```json\n{\n \"routes\": [\n {\n \"legs\": [\n {\n \"travelAdvisory\": {\n \"tollInfo\": {\n \"estimatedPrice\": [\n {\n \"currencyCode\": \"USD\",\n \"units\": \"4\",\n \"nanos\": 400000000\n }\n ]\n }\n }\n }\n ],\n \"distanceMeters\": 150338,\n \"duration\": \"6650s\",\n \"travelAdvisory\": {\n \"tollInfo\": {\n \"estimatedPrice\": [\n {\n \"currencyCode\": \"USD\",\n \"units\": \"4\",\n \"nanos\": 400000000\n }\n ]\n }\n }\n }\n ]\n}\n```"]]