המוצר או התכונה האלה נמצאים בסטטוס 'גרסה קודמת'. מידע נוסף על סטטוס מדור קודם ועל מעבר משירותים מדור קודם לשירותים חדשים יותר זמין במאמר
מוצרים ותכונות מדור קודם.
סקירה כללית על Directions API (קודם)
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מפתחים באזור הכלכלי האירופי (EEA)

Directions API (גרסה קודמת) הוא שירות שמקבל בקשת HTTP ומחזיר הוראות הגעה בין מיקומים בפורמט JSON או XML.
למה כדאי להשתמש ב-Directions API
באמצעות Directions API, אפשר לקבל מסלולים לכמה אמצעי תחבורה, כמו תחבורה ציבורית, נהיגה, הליכה או רכיבה על אופניים.
מה אפשר לעשות באמצעות Directions API?
באמצעות Directions API אפשר לחשב מסלולים בין מיקומים, כולל הפרטים הבאים:
- מסלולים לכמה אמצעי תחבורה, כולל תחבורה ציבורית, נהיגה, הליכה או רכיבה על אופניים.
- מסלולים מרובי חלקים באמצעות סדרה של נקודות ציון.
- אפשר לציין מקורות, יעדים ונקודות עצירה בכמה דרכים, כולל כמחרוזות טקסט (לדוגמה, 'שיקגו, אילינוי' או 'דרווין, הטריטוריה הצפונית, אוסטרליה'), מזהי מקומות או קואורדינטות של קו רוחב וקו אורך.
איך Directions API פועל
Directions API מחזיר את המסלולים הכי יעילים כשמחשבים מסלולים. כדי לקבוע את המסלול היעיל ביותר, המוצר מביא בחשבון את רכיבי הנסיעה הבאים:
- זמן הגעה (ראשי)
- מרחק
- מספר התורות
בדוגמת הבקשה הבאה מוחזרות הוראות נסיעה מטורונטו, אונטריו למונטריאול, קוויבק בפורמט JSON:
https://maps.googleapis.com/maps/api/directions/json
?destination=Montreal
&origin=Toronto
&key=YOUR_API_KEY
משאבים
בטבלה הבאה מפורטים המשאבים שזמינים דרך Directions API והנתונים שמוחזרים.
מקורות נתונים |
נתונים שהוחזרו |
פורמט ההחזרה |
מסלול
מציינים את נקודות המוצא והיעד באמצעות מזהי מקומות, כתובות או קואורדינטות של קווי רוחב ואורך. פרטים נוספים זמינים במאמר בנושא פרמטרים נדרשים.
|
הוראות מפורטות, מחולקות למסלולים, לקטעים ולשלבים. פרטים נוספים זמינים במאמר בנושא תשובות לשאילתות על מסלולים.
|
|
איך משתמשים ב-Directions API
1 |
הגדרה |
מתחילים עם הגדרת הפרויקט ב-Google Cloud ומשלימים את הוראות ההגדרה שבהמשך. |
2 |
לניסיון ההדגמה |
אחרי שיש לכם מפתח API ופרויקט בענן, אתם יכולים לנסות את הדמו של שירות הניווט ללא תשלום. הדגמה של Directions API
|
3 |
יצירת בקשה |
אפשר לעיין בדוגמאות לבקשות ולקבל מידע על האפשרויות הזמינות שאפשר לציין, כמו אמצעי תחבורה, נקודות ציון והגבלות על מסלולים. דוגמאות להוראות הגעה
|
4 |
הסבר על תשובות |
כדאי לעיין בתשובות של נתוני המסלולים כדי להתכונן לשימוש בנתוני מסלולים באפליקציה. פרטים נוספים זמינים במאמר בנושא תשובות של נתוני מסלולים.
|
5 |
שילוב נתוני כיוון באפליקציה שלכם |
אפשר להשתמש בנתונים האלה כדי לחשב את מרחק הנסיעה ואת זמן הנסיעה.
|
ספריות לקוח זמינות
אפשר לקרוא ל-API הזה בשפה הרצויה באמצעות אחת מספריות הלקוח הבאות:
הלקוחות של Java, Python, Go ו-Node.js עבור Google Maps Services הם ספריות לקוח עם תמיכה מהקהילה, שזמינות בקוד פתוח במסגרת רישיון Apache 2.0.
אפשר להוריד אותם מ-GitHub, שם אפשר למצוא גם הוראות התקנה וקוד לדוגמה.
המאמרים הבאים
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-31 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-31 (שעון UTC)."],[[["\u003cp\u003eThe Directions API provides route information between locations using various transportation modes like driving, walking, transit, or bicycling.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize your requests by specifying origins, destinations, waypoints, and travel preferences.\u003c/p\u003e\n"],["\u003cp\u003eThe API calculates the most efficient routes based on travel time, distance, and the number of turns.\u003c/p\u003e\n"],["\u003cp\u003eResults are available in JSON or XML format and include detailed directions, routes, legs, and steps.\u003c/p\u003e\n"],["\u003cp\u003eClient libraries are available in Java, Python, Go, and Node.js for easy integration into your applications.\u003c/p\u003e\n"]]],[],null,["# Directions API (Legacy) overview\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\nThe Directions API (Legacy) is a service that accepts an HTTP request and returns JSON or XML-formatted directions between locations.\n\nWhy use the Directions API\n--------------------------\n\nWith the Directions API, you can get directions for several modes of\ntransportation, such as transit, driving, walking, or bicycling.\n\nWhat you can do with the Directions API?\n----------------------------------------\n\nWith the Directions API, you can calculate directions between locations,\nincluding the following details:\n\n- Directions for several modes of transportation, including transit, driving, walking or bicycling.\n- Multipart directions using a series of waypoints.\n- Specify origins, destinations, and waypoints in multiple ways, including as text strings (for example, \"Chicago, IL\" or \"Darwin, NT, Australia\"), place IDs, or latitude/longitude coordinates.\n\nHow the Directions API works\n----------------------------\n\nThe Directions API returns the most efficient routes when\ncalculating directions. The product factors in the following travel elements\nwhen determining the most efficient route:\n\n- Travel time (primary)\n- Distance\n- Number of turns\n\nThe following example request returns driving directions from Toronto, Ontario to Montreal, Quebec in JSON format: \n\n```scdoc\nhttps://maps.googleapis.com/maps/api/directions/json\n ?destination=Montreal\n &origin=Toronto\n &key=YOUR_API_KEY\n```\n\n### Resources\n\nThe following table summarizes the resources available through the\nDirections API along with the data it returns.\n\n\u003cbr /\u003e\n\n| Data resources | Data returned | Return format |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|\n| [Directions](/maps/documentation/directions/get-directions#DirectionsRequests) Supply origins and destinations in the form of place IDs, addresses, or latitude/longitude coordinates. See [required parameters](/maps/documentation/directions/get-directions#required-parameters) for details. | Detailed directions, broken into routes, legs, and steps. See [Directions responses](/maps/documentation/directions/get-directions#DirectionsResponses) for details. | - JSON - XML |\n\n\u003cbr /\u003e\n\nHow to use the Directions API\n-----------------------------\n\n|---|---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1 | **Get set up.** | Start with [Set up your Google Cloud project](/maps/documentation/directions/cloud-setup) and complete the setup instructions that follow. |\n| 2 | **Try the demo** | Once you have an API key and a cloud project you try out the directions demo at no charge. See [The Directions API demo](/maps/documentation/directions/start). |\n| 3 | **Build a request** | See the example requests and learn about the available options you can supply, such as travel modes, waypoints, and route restrictions. See [Directions examples](/maps/documentation/directions/get-directions#ExampleRequests). |\n| 4 | **Understand response basics** | Explore the data responses to prepare to use directions data for your app. See [Directions responses](/maps/documentation/directions/get-directions#DirectionsResponses) for details. |\n| 5 | **Incorporate direction data into your own app!** | You can use this data to calculate travel distance and time. |\n\n#### Available client libraries\n\nCall this API in the language of\nyour choice through one of the following client libraries:\n\n- [Java\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-java)\n- [Python\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-python)\n- [Go Client\n for Google Maps Services](https://github.com/googlemaps/google-maps-services-go)\n- [Node.js\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-js)\n\nThe Java Client, Python Client, Go Client and Node.js Client for Google Maps\nServices are community-supported client libraries, open sourced under the\n[Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).\nDownload them from GitHub, where you can also find installation instructions and sample code.\n\nWhat's next\n-----------\n\n- **Start using the Directions API** : Go to [Get started](/maps/documentation/directions/start).\n- **Start making Directions requests** : Go to [Get\n directions](/maps/documentation/directions/get-directions).\n- **Follow best practices** : Go to [Web service best\n practices](/maps/documentation/directions/web-service-best-practices)."]]