جرّب الجيل التالي من ميزات مصفوفة المسافة من خلال
Routes API.
بدء استخدام واجهة برمجة التطبيقات لمصفوفة المسافات
نموذج طلب واستجابة
يطلب هذا المثال بيانات مصفوفة المسافات بين واشنطن العاصمة و
مدينة نيويورك بتنسيق JSON:
https://maps.googleapis.com/maps/api/distancematrix/json
?destinations=New%20York%20City%2C%20NY
&origins=Washington%2C%20DC
&units=imperial
&key=YOUR_API_KEY
curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=Washington%2C%20DC&destinations=New%20York%20City%2C%20NY&units=imperial&key=YOUR_API_KEY'
جرِّبه الآن اختبِر هذا الطلب عن طريق إدخال عنوان URL في متصفّح الويب، واحرص على
استبدال YOUR_API_KEY
بـ مفتاح واجهة برمجة التطبيقات الفعلي.
يعرض الردّ المسافة والمدة بين نقاط المغادرة
والوجهات المحدّدة.
تعرَّف على كيفية إنشاء عناوين URL للطلبات،
بما في ذلك جميع المَعلمات المتاحة.
يتوفّر نموذج الرمز البرمجي هذا بتنسيقَي JSON وXML:
{
"destination_addresses": ["New York, NY, USA"],
"origin_addresses": ["Washington, DC, USA"],
"rows":
[
{
"elements":
[
{
"distance": { "text": "228 mi", "value": 367654 },
"duration": { "text": "3 hours 55 mins", "value": 14078 },
"status": "OK",
},
],
},
],
"status": "OK",
}
<DistanceMatrixResponse>
<status>OK</status>
<origin_address>Washington, DC, USA</origin_address>
<destination_address>New York, NY, USA</destination_address>
<row>
<element>
<status>OK</status>
<duration>
<value>14078</value>
<text>3 hours 55 mins</text>
</duration>
<distance>
<value>367654</value>
<text>228 mi</text>
</distance>
</element>
</row>
</DistanceMatrixResponse>
اطّلِع على دليل المطوّر لفهم الردّ.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-01-14 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-01-14 (حسب التوقيت العالمي المتفَّق عليه)"],[[["This page provides a sample request and response for the Distance Matrix API, demonstrating how to calculate the distance and travel time between two locations."],["The example uses Washington, DC and New York City, NY as locations and showcases the request URL, cURL command, and expected JSON/XML responses."],["Users are encouraged to try the example with their own API key and explore further documentation on building requests and understanding responses."]]],["The content demonstrates requesting distance data between Washington, DC, and New York City using the Google Maps Distance Matrix API. The request URL and cURL command are provided, requiring the user to replace `YOUR_API_KEY` with their own. The API returns distance (228 mi) and duration (3 hours 55 mins) data in both JSON and XML formats. Users can test the URL and further understand responses, and can learn to build custom URL requests through provided documentation.\n"]]