Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Buscar en la ruta
Para usar Text Search (nuevo) y realizar búsquedas a lo largo de una ruta, pasa la ruta precalculada de la API de Routes en la solicitud como una polilínea. La respuesta contiene lugares que coinciden con los criterios de búsqueda y que también se encuentran cerca de la ruta especificada.
Para buscar a lo largo de una ruta, sigue estos pasos:
Usa el parámetro searchAlongRouteParameters.polyline.encodedPolyline para pasar la polilínea codificada de la ruta a Text Search (nuevo) y sesgar los resultados de la búsqueda hacia la ruta. Luego, la respuesta contiene lugares que coinciden con los criterios de búsqueda y que también se encuentran cerca de la ruta especificada.
El Explorador de APIs te permite realizar solicitudes en vivo para que puedas familiarizarte con la API y sus opciones:
De forma predeterminada, Text Search (nuevo) realiza la búsqueda a lo largo de toda la ruta, desde el origen hasta el destino, según lo define la polilínea. En el siguiente ejemplo, la polilínea define la ruta desde:
Origen: 1600 Amphitheatre Parkway, Mountain View, CA
Destino: 24 Willie Mays Plaza, San Francisco, CA
La polilínea codificada del viaje para esta ruta se representa con la siguiente cadena:
No es necesario que sesgues los resultados hacia toda la ruta. Por ejemplo, es posible que ya estés a mitad de la ruta antes de realizar la búsqueda. En este caso, puedes especificar un origen de enrutamiento explícito para la búsqueda y anular el origen definido en la polilínea codificada. En el siguiente ejemplo, se especifican las coordenadas de latitud y longitud de San Mateo, California, que se encuentra aproximadamente a mitad de la polilínea de la ruta:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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."]]