המוצר או התכונה האלה בסטטוס 'קודם'. מידע נוסף על השלב 'דור קודם' ועל המעבר מדור קודם לשירותים חדשים זמין במאמר
מוצרים ותכונות מדור קודם.
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
תחילת השימוש ב-Distance Matrix API (גרסה קודמת)
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
דוגמה לבקשה ולתגובה
בדוגמה הזו מתבצעת בקשה לנתוני מטריצת המרחקים בין וושינגטון די.סי. לבין ניו יורק סיטי, ניו יורק, בפורמט JSON:
כתובת URL
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
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 במפתח ה-API בפועל. התשובה תציג את המרחק והמשך בין נקודות המוצא והיעדים שצוינו.
איך יוצרים כתובות URL של בקשות, כולל כל הפרמטרים הזמינים.
דוגמת הקוד הזו היא בפורמטים JSON ו-XML:
JSON
{
"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",
}
XML
OK
Washington, DC, USA
New York, NY, USA
OK
14078
3 hours 55 mins
367654
228 mi
כדאי לעיין במדריך למפתחים כדי להבין את התשובה.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2026-04-29 (שעון UTC).
[null,null,["עדכון אחרון: 2026-04-29 (שעון UTC)."],[],["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"]]