ภาพรวม Roads API
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Roads API เป็นบริการที่ยอมรับคำขอ HTTPS ที่มีพิกัดละติจูด/ลองจิจูดสำหรับจุดอย่างน้อย 1 จุดบนแผนที่ โดยจะใช้จุดเหล่านี้เพื่อค้นหาส่วนของถนนที่อยู่ใกล้เคียง และแสดงรหัสสถานที่พร้อมข้อมูลเมตา เช่น ส่วนของถนนที่ใกล้ที่สุดและขีดจำกัดความเร็ว
ทำไมถึงต้องใช้ Roads API
Roads API ช่วยให้คุณทราบขีดจำกัดความเร็ว เวลาถึงโดยประมาณ
หรือข้อมูลเมตาอื่นๆ ของถนน ข้อมูลเมตาของถนนนี้ช่วยให้คุณเพิ่มความสามารถต่อไปนี้ลงในแอปการขับขี่ได้
- เชื่อมต่อพิกัดละติจูด/ลองจิจูดกับถนน
- ค้นหาถนนที่ใกล้ที่สุดสำหรับชุดพิกัด
- รับการจำกัดความเร็วสำหรับส่วนของถนน
สิ่งที่คุณทำได้ด้วย Roads API
Roads APIช่วยให้คุณแมปพิกัด GPS กับ
เรขาคณิตของถนน และกำหนดขีดจำกัดความเร็วตาม
ส่วนของถนนได้
- การปรับให้ตรงกับถนน บริการนี้จะแสดงถนนที่มีความเป็นไปได้มากที่สุด
ซึ่งมีการเดินทางตามชุดพิกัด GPS ที่ระบุ คุณระบุจุด GPS ที่รวบรวมตามเส้นทางได้สูงสุด 100 จุด นอกจากนี้ คุณยังขอให้บริการประมาณค่าจุดเพิ่มเติมได้ด้วย
ซึ่งจะทำให้เส้นทางเป็นไปตามรูปทรงของถนนอย่างราบรื่น
- ถนนที่ใกล้ที่สุด บริการนี้จะแสดงส่วนของถนนที่ใกล้ที่สุดสำหรับจุด GPS คุณระบุจุด GPS ได้สูงสุด 100 จุด จุดที่คุณระบุไม่จำเป็นต้องเป็นส่วนหนึ่งของเส้นทางต่อเนื่อง
- ขีดจำกัดความเร็ว บริการนี้จะแสดงขีดจำกัดความเร็วที่ประกาศไว้สำหรับส่วนของถนน
บริการจำกัดความเร็วพร้อมให้บริการแก่ลูกค้าทุกรายที่มีใบอนุญาตติดตามชิ้นงาน
สำหรับลูกค้า Google Maps Platform Premium Plan
ที่เปลี่ยนไปใช้ราคาแบบจ่ายตามการใช้งาน ฟีเจอร์นี้จะยังคง
ใช้งานได้
วิธีการทำงานของ Roads API
Roads API ใช้ปลายทาง 3 รายการที่ยอมรับพิกัดละติจูด/ลองจิจูด
หรือรหัสสถานที่เพื่อระบุเส้นทาง ถนน หรือข้อมูลจำกัดความเร็ว
ตัวอย่างต่อไปนี้แสดงคำขอถนนที่ใกล้ที่สุดตามชุดพิกัดละติจูด/ลองจิจูด
https://roads.googleapis.com/v1/nearestRoads
?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796
&key=YOUR_API_KEY
แหล่งข้อมูล
ตารางต่อไปนี้สรุปแหล่งข้อมูลที่พร้อมใช้งานผ่าน
Roads API พร้อมกับข้อมูลที่แสดงผล
แหล่งข้อมูล |
ข้อมูลที่แสดงผล |
รูปแบบการแสดงผล |
ลากเส้นทางไปตามถนน
|
แสดงผลอาร์เรย์ของจุด GPS สูงสุด 100 จุดจากเส้นทาง ประกอบด้วย
พิกัดลองจิจูด/ละติจูดที่ปรับตามถนน
พร้อมรหัสสถานที่ ดูรายละเอียดได้ใน
การตอบกลับ
ในคำแนะนำSnap to roads
|
|
ถนนที่ใกล้ที่สุด
|
อาร์เรย์ของพิกัดละติจูด/ลองจิจูดอิสระสูงสุด 100 รายการ
พร้อมด้วยรหัสสถานที่ของถนนที่ใกล้ที่สุดสำหรับแต่ละจุดที่ระบุ
ไม่จำเป็นต้องเป็นคะแนนต่อเนื่อง ดูรายละเอียดได้ใน
การตอบกลับ
ในคู่มือถนนที่ใกล้ที่สุด
|
การจำกัดความเร็ว
|
อาร์เรย์ขององค์ประกอบข้อมูลเมตาของถนนได้สูงสุด 100 รายการ ซึ่งประกอบด้วยขีดจำกัดความเร็วและรหัสสถานที่ โดยมีหน่วยเป็น KPH หรือ MPH ดูรายละเอียด
ในคำตอบ
ในคำแนะนำการจำกัดความเร็ว
|
วิธีใช้ Roads API
1 |
ลองใช้เดโมการติดถนน |
คลิกเดโมเพื่อสร้างเส้นทางและดูว่าปลายทาง Snap to Roads
ให้ข้อมูลที่ราบรื่นได้อย่างไร ดูการสาธิตในคำแนะนำสแนปไปยังถนน โดยไม่จำเป็นต้องใช้คีย์ API
|
2 |
เริ่มต้นใช้งาน |
เริ่มต้นด้วยตั้งค่า
โปรเจ็กต์ Google Cloud และทําตามวิธีการตั้งค่าที่ตามมา
จากนั้นดูวิธีใช้คีย์ API
|
3 |
ลองส่งคำขอ Snap to Roads |
ใช้ตัวอย่างการปักหมุด
บนถนนข้อใดข้อหนึ่ง แล้วลองใช้ตัวอย่างที่เกี่ยวข้องกับ Use Case ของคุณ
|
4 |
ดูการจำกัดความเร็วสำหรับเส้นทางถนน |
ใช้ข้อมูลเส้นทางเดียวกันกับที่คุณระบุสำหรับคำขอ Snap to Roads
ออกคำค้นหาขีดจำกัดความเร็ว ดู
ตัวอย่างคำขอที่ใช้เส้นทาง
|
5 |
ดูวิธีประมวลผลเส้นทางยาวๆ |
ดูส่วนต่างๆ เกี่ยวกับ
การประมวลผลเส้นทางยาว
ในคู่มือแนวคิดขั้นสูง
|
6 |
รวมข้อมูลถนนเข้ากับแอปของคุณเอง |
ดูตัวอย่างโค้ดแบบละเอียดจากเดโมการปรับถนนให้ตรงกับเส้นทางเพื่อเริ่ม
สร้างฟังก์ชันการทำงานของข้อมูลถนนลงในแอปของคุณเอง
|
ไลบรารีของไคลเอ็นต์ที่พร้อมใช้งาน
เรียกใช้ API นี้ในภาษาที่คุณเลือกผ่านไลบรารีของไคลเอ็นต์ต่อไปนี้
ไคลเอ็นต์ Java, ไคลเอ็นต์ Python, ไคลเอ็นต์ Go และไคลเอ็นต์ Node.js สำหรับบริการ Google Maps เป็นไลบรารีของไคลเอ็นต์ที่ได้รับการสนับสนุนจากชุมชนและเป็นโอเพนซอร์สภายใต้สัญญาอนุญาต Apache 2.0
ดาวน์โหลดได้จาก GitHub ซึ่งคุณจะดูวิธีการติดตั้งและโค้ดตัวอย่างได้ด้วย
ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 2025-08-31 UTC"],[[["\u003cp\u003eThe Roads API enhances maps applications by connecting coordinates with roads, finding nearby roads, and providing speed limit data.\u003c/p\u003e\n"],["\u003cp\u003eIt offers three core functionalities: snapping GPS points to roads, identifying nearest roads, and retrieving speed limits.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can leverage client libraries for Java, Python, Go, and Node.js to integrate the Roads API.\u003c/p\u003e\n"],["\u003cp\u003eThe API accepts latitude/longitude coordinates and returns data like Place IDs, road segments, and speed limits in JSON format.\u003c/p\u003e\n"],["\u003cp\u003eYou can get started by exploring the documentation, trying the demo, setting up a Google Cloud project, and experimenting with code examples.\u003c/p\u003e\n"]]],["The Roads API processes HTTPS requests with latitude/longitude coordinates to identify nearby road segments. It offers three main services: Snap to Roads, which maps up to 100 GPS points to road geometry; Nearest Roads, which identifies the closest road segment for up to 100 independent GPS points; and Speed Limits, which returns posted speed limits and place IDs for road segments. Users can integrate these functionalities using client libraries or by making direct requests with an API key.\n"],null,["# Roads API overview\n\nThe Roads API is a service that accepts HTTPS requests with latitude/longitude coordinates for one or more points on a map. It uses these points to find nearby road segments and returns a Place ID along with metadata such as the nearest road segment and speed limits.\n\nWhy use the Roads API\n---------------------\n\nWith the Roads API, you can get speed limits, estimated\narrival times, or other road metadata. With this road\nmetadata, you can enhance your driving apps with the follow capabilities:\n\n- Connect latitude/longitude coordinates with a road or roads.\n- Find the nearest road for a set of coordinates\n- Get speed limits for road segments\n\nWhat you can do with the Roads API\n----------------------------------\n\nWith the Roads API, you can map GPS coordinates to the\ngeometry of the road, and determine the speed limit along road\nsegments.\n\n- **[Snap to Roads](/maps/documentation/roads/snap)** This service returns the most likely roads traveled based on the provided set of GPS coordinates. You can specify up to 100 GPS points collected along a route. Optionally, you can also request that the service interpolates additional points, resulting in a path that smoothly follows the geometry of the road.\n- **[Nearest Roads](/maps/documentation/roads/nearest)** This service returns the nearest road segment for a GPS point. You can specify up to 100 GPS points. The points you specify don't need to be part of a continuous path.\n- **[Speed limits](/maps/documentation/roads/speed-limits)** This service returns the posted speed limit for a road segment. The Speed Limit service is available to all customers with an Asset Tracking license. For [Google Maps Platform Premium Plan](/maps/premium) customers who transitioned to pay-as-you-go pricing, the feature remains active.\n\nHow the Roads API works\n-----------------------\n\nThe Roads API uses three endpoints which accept latitude/longitude\ncoordinates or place IDs to provide road paths, segments, or speed limit data.\nThe following example shows a request for nearest roads based on a set\nof latitude/longitude coordinates: \n\n```scdoc\nhttps://roads.googleapis.com/v1/nearestRoads\n ?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796\n &key=YOUR_API_KEY\n```\n\n### Resources\n\nThe following table summarizes the resources available through the\nRoads API along with the data it returns.\n\n\u003cbr /\u003e\n\n| Data resources | Data returned | Return format |\n|------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|\n| **[Snap to roads](/maps/documentation/roads/snap)** | Returns an array of up to 100 GPS points from a route. Includes road-snapped longitude/latitude coordinates along with place IDs. See details in [Responses](/maps/documentation/roads/snap#responses) in the Snap to roads guide. | - JSON |\n| **[Nearest roads](/maps/documentation/roads/nearest)** | An array of up to 100 independent latitude/longitude coordinates along with place IDs for the nearest road for each specified point. Points do not need to be continuous. See details in [Responses](/maps/documentation/roads/nearest#responses) in the Nearest roads guide. | - JSON |\n| **[Speed limits](/maps/documentation/roads/speed-limits)** | An array of up to 100 road metadata elements. These contain speed limits and place IDs, with units either in KPH or MPH. See details in [Responses](/maps/documentation/roads/nearest#responses) in the Speed limits guide. | - JSON |\n\n\u003cbr /\u003e\n\nHow to use the Roads API\n------------------------\n\n|---|----------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1 | **Try the snap to roads demo** | Click the demo to create a track and see how the snap to roads endpoint provides smooth data. See [Demo](/maps/documentation/roads/snap#demo) in the **Snap to roads** guide. You don't need an API key. |\n| 2 | **Get set up** | Start with [Set up your Google Cloud project](/maps/documentation/roads/cloud-setup) and complete the setup instructions that follow and then learn [how to use your API key](/maps/documentation/roads/get-api-key). |\n| 3 | **Try a snap to roads request** | [Use one of the snap to roads examples](/maps/documentation/roads/snap#examples) and try one relevant to your use case. |\n| 4 | **Get speed limits for your road path** | Using the same path data you provided for your snap to roads request, issue a speed limit query. See the [Example request using a path](/maps/documentation/roads/speed-limits#example_request_using_a_path). |\n| 5 | **Learn how to process long paths** | Follow the sections on [Processing long paths](/maps/documentation/roads/advanced#processing_long_paths) in the **Advanced concepts** guide. |\n| 6 | **Incorporate road data into your own app!** | See the [detailed code example](/maps/documentation/roads/snap#javascript-+-html) from the road snapped demo to start building road data functionality into your own app. |\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- **Try out the Roads API** : Go to [Roads Inspector](/maps/documentation/roads/inspector)\n- **Learn how to make Roads API requests** : Go to the service you're interested in:\n - [Snap to roads](/maps/documentation/roads/snap)\n - [Nearest roads](/maps/documentation/roads/nearest)\n - [Speed limits](/maps/documentation/roads/speed-limits)\n- **Understand Advanced Concepts** : Go to [Advanced Concepts](/maps/documentation/roads/advanced)\n- **Follow best practices** : Go to [Web Services Best Practices](/maps/documentation/roads/web-service-best-practices)"]]