Panoramica dell'API Roads
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Roads API è un servizio che accetta richieste HTTPS con
coordinate di latitudine/longitudine per uno o più punti su una mappa. Utilizza questi
punti per trovare segmenti stradali nelle vicinanze e restituisce un ID luogo insieme a metadati
come il segmento stradale più vicino e i limiti di velocità.
Perché utilizzare Roads API
Con Roads API, puoi ottenere limiti di velocità, orari di arrivo stimati o altri metadati stradali. Con questi metadati
stradali, puoi migliorare le tue app di guida con le seguenti funzionalità:
- Collega le coordinate di latitudine/longitudine a una o più strade.
- Trovare la strada più vicina per un insieme di coordinate
- Ottenere i limiti di velocità per i segmenti stradali
Cosa puoi fare con Roads API
Con Roads API, puoi mappare le coordinate GPS sulla
geometria della strada e determinare il limite di velocità lungo i
segmenti stradali.
- Snap to Roads Questo servizio restituisce le strade percorse più probabili in base al set di coordinate GPS fornito. Puoi specificare
fino a 100 punti GPS raccolti lungo un percorso. Se vuoi,
puoi anche richiedere al servizio di interpolare punti aggiuntivi,
in modo da ottenere un percorso che segue in modo uniforme la geometria della strada.
- Nearest Roads Questo servizio restituisce il segmento di strada più vicino per un punto GPS. Puoi specificare fino a 100
punti GPS. I punti specificati non devono far parte di un percorso continuo.
- Limiti di velocità Questo servizio restituisce il limite di velocità registrato per un segmento di strada. Il servizio Limite di velocità è disponibile per tutti i clienti con una licenza Asset Tracking. Per i clienti del piano Premium di Google Maps Platform che sono passati al pagamento a consumo, la funzionalità rimane attiva.
Come funziona Roads API
Roads API utilizza tre endpoint che accettano coordinate di latitudine/longitudine o ID luogo per fornire percorsi stradali, segmenti o dati sui limiti di velocità.
L'esempio seguente mostra una richiesta delle strade più vicine in base a un insieme
di coordinate di latitudine/longitudine:
https://roads.googleapis.com/v1/nearestRoads
?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796
&key=YOUR_API_KEY
Risorse
La tabella seguente riepiloga le risorse disponibili tramite
Roads API e i dati restituiti.
Risorse di dati |
Dati restituiti |
Formato del reso |
Posiziona su strada
|
Restituisce un array di massimo 100 punti GPS di un percorso. Include
coordinate di longitudine/latitudine allineate alla strada
insieme agli ID luogo. Per i dettagli, consulta la sezione
Risposte
della guida
Snap to roads.
|
|
Strade più vicine
|
Un array di massimo 100 coordinate di latitudine/longitudine indipendenti
insieme agli ID luogo della strada più vicina per ogni punto specificato.
I punti non devono essere continui. Per maggiori dettagli, consulta la sezione
Risposte
della guida
Strade più vicine.
|
Limiti di velocità
|
Un array di massimo 100 elementi di metadati stradali. Questi contengono limiti di velocità e ID luogo, con unità in km/h o mph. Consulta i dettagli
in Risposte
nella guida Limiti di velocità.
|
Come utilizzare Roads API
1 |
Prova la demo dell'aderenza alle strade |
Fai clic sulla demo per creare una traccia e vedere come l'endpoint Snap to Roads
fornisce dati uniformi. Consulta la
demo
nella guida Aggancia alle strade. Non è necessaria una chiave API.
|
2 |
Configurazione |
Inizia con Configurare il tuo
progetto Google Cloud e completa le istruzioni di configurazione riportate di seguito
e poi scopri
come utilizzare la chiave API.
|
3 |
Prova una richiesta di snap to roads |
Utilizza uno degli esempi di snap
to roads e prova quello più pertinente al tuo caso d'uso.
|
4 |
Visualizzare i limiti di velocità per il tuo percorso stradale |
Utilizzando gli stessi dati del percorso che hai fornito per la richiesta di snap to roads,
invia una query sul limite di velocità. Vedi l'esempio di richiesta che utilizza un percorso.
|
5 |
Scopri come elaborare i percorsi lunghi |
Segui le sezioni relative a
Elaborazione di percorsi lunghi
nella guida Concetti avanzati.
|
6 |
Integra i dati stradali nella tua app. |
Consulta l'esempio di codice dettagliato della demo di snapping stradale per iniziare a integrare la funzionalità dei dati stradali nella tua app.
|
Librerie client disponibili
Chiama questa API nella lingua di tua scelta tramite una delle seguenti librerie client:
I client Java, Python, Go e Node.js per i servizi Google Maps sono librerie client supportate dalla community, open source con licenza Apache 2.0.
Scaricali da GitHub, dove puoi trovare anche le istruzioni di installazione e il codice campione.
Passaggi successivi
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-08-31 UTC.
[null,null,["Ultimo aggiornamento 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)"]]