Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Cerca lungo il percorso
Per utilizzare Ricerca di testo (nuova) per cercare lungo un percorso, passa il percorso precalcolato
dall'API Routes nella
richiesta come polilinea. La risposta contiene i luoghi che corrispondono ai criteri di ricerca e che si trovano anche vicino all'itinerario specificato.
Utilizza il parametro searchAlongRouteParameters.polyline.encodedPolyline per
trasferire la polilinea codificata dell'itinerario alla ricerca di testo (nuova) per orientare i risultati di ricerca
verso l'itinerario. La risposta contiene quindi i luoghi che corrispondono ai
criteri di ricerca e che si trovano anche vicino all'itinerario specificato.
L'API Explorer ti consente di effettuare richieste in tempo reale per familiarizzare con
l'API e le relative opzioni:
Per impostazione predefinita, Text Search (New) esegue la ricerca lungo l'intero percorso dall'origine alla destinazione come definito dalla polilinea. Nell'esempio
seguente, la polilinea definisce il percorso da:
Origine: 1600 Amphitheatre Parkway, Mountain View, CA, USA
Destinazione: 24 Willie Mays Plaza, San Francisco, CA
La polilinea codificata del viaggio per questo percorso è rappresentata dalla stringa:
Non devi distorcere i risultati per l'intero percorso. Ad esempio, potresti
aver già percorso metà del percorso prima di eseguire la ricerca. In questo caso,
puoi specificare un'origine di routing esplicita per la ricerca per ignorare l'origine
definita nella polilinea codificata. Nell'esempio seguente, vengono specificate le coordinate di latitudine e longitudine di San Mateo, CA, che si trova circa a metà del percorso polilinea:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eText Search can be used to find places along a route calculated by the Routes API by providing the route's encoded polyline.\u003c/p\u003e\n"],["\u003cp\u003eThe search results are biased towards the provided route, returning places that match the search criteria and are near the route.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify a starting point along the route to refine the search, such as searching for places from a specific location along the route to the destination.\u003c/p\u003e\n"],["\u003cp\u003eSearch along route returns places with minimal detour times from origin to destination, so if the origin and destination are the same or close, it may not return any results.\u003c/p\u003e\n"]]],["To search along a route, use the Routes API to calculate a route and obtain its encoded polyline. Then, use the `searchAlongRouteParameters.polyline.encodedPolyline` parameter in the Text Search (New) request to specify this polyline. This biases the search results to places near the route. Optionally, you can define a `routingParameters.origin` to search from a specific point along the route instead of the polyline's origin. You can then experiment using APIs Explorer.\n"],null,["Search along route\n==================\n\nTo use [Text Search (New)](/maps/documentation/places/web-service/text-search) to search along a route, pass the precalculated route\nfrom the [Routes API](/maps/documentation/routes/compute_route_directions) in\nthe request as a polyline. The response contains places that match the search\ncriteria and are also located near the specified route.\n\nTo search along a route:\n\n1. Use the Routes API to calculate a route that [returns a route's encoded\n polyline](/maps/documentation/routes/traffic_on_polylines) in the response.\n\n | **Note:** You can also encode your own polyline as described in [Encoded\n | Polyline Algorithm Format](/maps/documentation/utilities/polylinealgorithm).\n2. Use the `searchAlongRouteParameters.polyline.encodedPolyline` parameter to\n pass the route's encoded polyline to Text Search (New) to bias the search\n results to the route. The response then contains places that match the\n search criteria and are also located near the specified route.\n\nThe APIs Explorer lets you make live requests so that you can get familiar with\nthe API and the API options: \n[Try it!](#try_it)\n\nBy default, Text Search (New) performs the search along the entire route from\nthe origin to the destination as defined by the polyline. In the following\nexample, the polyline defines the route from:\n\n- **Origin**: 1600 Amphitheatre Parkway, Mountain View, CA\n- **Destination**: 24 Willie Mays Plaza, San Francisco, CA\n\nThe trip's encoded polyline for this route is represented by the string: \n\n```yaml\nwblcFptchVIFOd@G@EVw@Ms@dHKR}ApNA`AF~@Hf@TjAb@bBb@~@n@p@^Rd@~@Vz@HVz@nDLt@?d@Kr@c@~@mD`G?`@aEfGkCnDuChDm`@bb@[`@{GhHeEdEciBnnBkC`DkC~DaClEuKjT_Z|l@Qb@iR~_@}EzJ_AdB_Und@kAfCaOjZkg@vcAqBzD_]rr@iBlEaBxEgArD}AlG}AhHsA`IeAnH{@dIq@dJgL~iBq@rHu@vGgAtHwArHaBhHkBzG_DpJ}Nbc@iBhGkA|EgC|LcIjb@oAhG_AvDgAdDkApC_BzCiBpCsFvGii@vn@scAxlAmLjNgSzUeRjT{TzWqExEmG|FuNlMmMhLaRvPqOlNmbAl}@mFlF{PlOmJfIoElE}LtMiSbU_H`I}}@jcAwl@vp@oAbBqA~BeAhCm@tBg@fCWrBQ~BI|DaB~rBO~D[bEa@`Dm@pDaAdE{@vC_BbEkB~Def@|z@sEzHKJeS~]}K`S{\\\\~l@cXpe@sBpDm@bAuCxDkBrBiC~BwCtByBnAcBx@}Bt@{Bn@gh@|LaOpDeFhAoDj@aE^kVrA_E^iEr@yD~@uBr@gMjF_EnAcCh@eFr@_DRsAD}@Jsu@xCWDqIV}BCeCOyDm@cBa@_DmA}JeE_CwAsBcBiBoBuAqBmOoX{CuEkB_CoDqDkVoUoD{CeE_DkEkC_FeCqB}@sDuAoDgAeCe@cCW}CK}BDaDTeOlBcuBrYaNlBq@Dyd@rGyFt@yBb@eBf@oCnAoBlAkIpGkAp@wBbAaCt@oFdAwKjBoGxA{FbByIjC_HfB_@KmNdDuC|@uFzBcH|C{@\\\\[?sBv@}@VaBVoA@y@EmAQcA[w@]aBkAeAkA}BuDUKs@uAqBsCwBcCgAiAiN_MyKsJsG{GkBaBiBuA{BwAwDkBcOaHiC_AiCg@}BQcCAcBHqBVkB`@qEjAu@LgCVgAHwG@sG?mABsH^eNr@mBXy@NqBt@uAt@aBlAkAlA}BtCyApBiAdB_BxB{A`B}@j@oAf@s@PeCVcIf@gAAkAQy@YiAo@_A{@_DgEgJqM_DeEaM}PoBiCzAsBw@kAdAGVk@f@q@z@C\n```\n| **Note:** Search along route only supports an encoded polyline, which can be passed as a string and includes compression with minimal lossiness. This is the Routes API default output. For more information, see [Request route\n| polylines](/maps/documentation/routes/traffic_on_polylines).\n\nThe following example uses the route's encoded polyline to bias the search\nresults: \n\n```scdoc\n curl -X POST -d '{\n \"textQuery\" : \"Spicy Vegetarian Food\",\n \"searchAlongRouteParameters\": {\n \"polyline\": {\n \"encodedPolyline\": \"\u003cvar translate=\"no\"\u003eROUTE_POLYLINE\u003c/var\u003e\"\n }\n }\n }' \\\n -H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \\\n -H 'X-Goog-FieldMask: places.displayName,places.formattedAddress,places.priceLevel' \\\n 'https://places.googleapis.com/v1/places:searchText'\n```\n\nThe response contains the places that match the search criteria, biased to the\nroute: \n\n```yaml\n {\n \"places\": [\n {\n \"formattedAddress\": \"60 Morris St, San Francisco, CA 94107, USA\",\n \"priceLevel\": \"PRICE_LEVEL_MODERATE\",\n \"displayName\": {\n \"text\": \"Umami Express\",\n \"languageCode\": \"en\"\n }\n },\n {\n \"formattedAddress\": \"1130 4th St, San Francisco, CA 94158, USA\",\n \"priceLevel\": \"PRICE_LEVEL_MODERATE\",\n \"displayName\": {\n \"text\": \"House of Tadu Ethiopian Kitchen\",\n \"languageCode\": \"en\"\n }\n },\n {\n \"formattedAddress\": \"1602 El Camino Real Ste A, Belmont, CA 94002, USA\",\n \"priceLevel\": \"PRICE_LEVEL_MODERATE\",\n \"displayName\": {\n \"text\": \"Eats Meets West Bowls\",\n \"languageCode\": \"en\"\n }\n },\n /.../\n ]\n }\n```\n\nYou don't have to bias the results to the entire route. For example, you might\nalready be halfway along the route before you perform the search. In this case,\nyou can specify an explicit routing origin to the search to override the origin\ndefined in the encoded polyline. In the following example, you specify the\nlatitude and longitude coordinates of San Mateo, CA, which is approximately\nhalfway along the route polyline: \n\n```scdoc\n curl -X POST -d '{\n \"textQuery\" : \"Spicy Vegetarian Food\",\n \"searchAlongRouteParameters\": {\n \"polyline\": {\n \"encodedPolyline\": \"\u003cvar translate=\"no\"\u003eROUTE_POLYLINE\u003c/var\u003e\"\n }\n },\n \"routingParameters\": {\n \"origin\": {\n \"latitude\": 37.56617,\n \"longitude\": -122.30870\n }\n }\n }' \\\n -H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \\\n -H 'X-Goog-FieldMask: places.displayName,places.formattedAddress,places.priceLevel' \\\n 'https://places.googleapis.com/v1/places:searchText'\n```\n| **Note:** Because search along route returns places with minimal detour times from origin to destination, in cases where the route origin and destination are the same or close to one another, search along route may not return any results.\n\nTry it!\n-------\n\nThe APIs Explorer lets you make sample requests so\nthat you can get familiar with the API and the API options.\n\n1. Select the API icon api\n on the right side of the page.\n\n2. Optionally edit the request parameters.\n\n3. Select the **Execute** button. In the dialog, choose the account\n that you want to use to make the request.\n\n4. In the APIs Explorer panel, select the fullscreen icon\n fullscreen to expand the APIs Explorer window."]]