با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
خلاصه های مسیریابی را با جستجو در طول مسیر ترکیب کنید
می توانید محاسبات خلاصه مسیریابی را با جستجو در طول یک مسیر ترکیب کنید. در این حالت، جستجوی متن (جدید) مدت زمان سفر و مسافت را به هر مکان در پاسخ و سپس از هر مکان به مقصد نهایی مسیر برمیگرداند.
برای استفاده از جستجوی متن (جدید) برای محاسبه خلاصه مسیریابی به همراه جستجو در طول یک مسیر:
از searchAlongRouteParameters.setPolyline() برای ارسال چند خط مسیر به جستجوی متن (جدید) استفاده کنید تا نتایج جستجو را به مسیر سوگیری کنید. سپس پاسخ حاوی مکان هایی است که با معیارهای جستجو مطابقت دارند و همچنین در نزدیکی مسیر مشخص شده قرار دارند.
هنگام ساختن شی درخواست، .setRoutingSummariesIncluded(true) را اضافه کنید.
به طور پیش فرض، جستجوی متن (جدید) جستجو را در کل مسیر انجام می دهد:
// Define the route polyline object using the route string.EncodedPolylineencodedPolyline=EncodedPolyline.newInstance("wblcFptchVIFOd@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");// Specify the list of fields to return.finalList<Place.Field>placeFields=Arrays.asList(Place.Field.ID,Place.Field.NAME);// Define the search along route parameters object and pass the polyline object.SearchAlongRouteParameterssearchAlongRouteParameters=SearchAlongRouteParameters.builder().setPolyline(encodedPolyline).build();// Use the builder to create a SearchByTextRequest object and pass the search along route parameters.finalSearchByTextRequestsearchByTextRequest=SearchByTextRequest.builder("Spicy Vegetarian Food",placeFields).setMaxResultCount(10).setSearchAlongRouteParameters(searchAlongRouteParameters).setRoutingSummariesIncluded(true).build();// Call PlacesClient.searchByText() to perform the search.// Define a response handler to process the returned List of Place objects.placesClient.searchByText(searchByTextRequest).addOnSuccessListener(response->{List<Place>places=response.getPlaces();List<RoutingSummary>routingSummaries=response.getRoutingSummaries();List<Leg>legs=routingSummaries.get(0).getLegs();Durationduration=legs.get(0).getDuration();});
پاسخ شامل اشیایی است که شامل لیستی از فیلدهای مکان های درخواستی و خلاصه مسیریابی است که شامل مدت زمان و مسافت سفر به هر مکان است. برای برگرداندن فهرست خلاصههای مسیریابی، میتوانید SearchByTextResponse.getRoutingSummaries() را فراخوانی کنید.
برای هر ورودی در آرایه legs ، جستجوی متن (جدید) زمان سفر دو مرحله ای را برمی گرداند:
مرحله اول شامل مدت زمان سفر و فاصله از مبدا تا مکان است.
گام دوم شامل مدت زمان سفر و فاصله از مکان تا مقصد مسیر است.
مبدا مسیریابی، حالت سفر و اصلاح کننده های مسیر را مشخص کنید
میتوانید با تعیین مبدا مسیریابی، حالت سفر، اصلاحکنندههای مسیر و اولویتهای مسیریابی، محاسبه خلاصه جستجو و مسیریابی را تغییر دهید. حالت سفر و اصلاحکنندههای مسیر مانند محاسبه خلاصههای مسیریابی بدون تعیین مسیر، همانطور که در مبحث گزینههای سفر مشخص شده است، کار میکنند.
به طور پیش فرض، اولین پا از هر نتیجه شامل فاصله از مبدا تعریف شده توسط چند خط تا هر مکان است. با این حال، می توانید با مشخص کردن صریح مبدا مسیریابی در درخواست، آن پیش فرض را لغو کنید. اگر مشخص شده باشد، اولین پا از همه پاسخها، فواصل و مدت زمان را از مبدا مسیریابی مشخص شده مشخص میکند و مبدأ از چند خط را لغو میکند.
در مثال بعدی، یک مبدأ مسیریابی را به عنوان مختصات San Mateo، CA مشخص میکنید، برای اجتناب از عوارض تعیین میکنید و تعداد نتایج را روی 5 تنظیم میکنید:
// Define the route polyline object using the route string.EncodedPolylineencodedPolyline=EncodedPolyline.newInstance("wblcFptchVIFOd@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");// Specify the list of fields to return.finalList<Place.Field>placeFields=Arrays.asList(Place.Field.ID,Place.Field.NAME);// Define the routing modifiers object.RouteModifiersrouteModifiers=RouteModifiers.builder().setAvoidTolls(true).build();// Define the routing parameters object and pass the routing origin.// Set the travel mode to DRIVE.// Pass the routeModifiers object.RoutingParametersroutingParameters=RoutingParameters.builder().setOrigin(toLatLng("37.56617, -122.30870")).setTravelMode(DRIVE).setRouteModifiers(routeModifiers).build();// Define the search along route parameters object and pass the polyline object.SearchAlongRouteParameterssearchAlongRouteParameters=SearchAlongRouteParameters.builder().setPolyline(encodedPolyline).build();// Use the builder to create a SearchByTextRequest object and pass the search along route parameters.finalSearchByTextRequestsearchByTextRequest=SearchByTextRequest.builder("Spicy Vegetarian Food",placeFields).setMaxResultCount(5).setRoutingParameters(routingParameters).setSearchAlongRouteParameters(searchAlongRouteParameters).setRoutingSummariesIncluded(true).build();// Call PlacesClient.searchByText() to perform the search.// Define a response handler to process the returned List of Place objects.placesClient.searchByText(searchByTextRequest).addOnSuccessListener(response->{List<Place>places=response.getPlaces();List<RoutingSummary>routingSummaries=result.getRoutingSummaries();List<Leg>legs=routingSummaries.get(0).getLegs();Durationduration=legs.get(0).getDuration();});
تصویر زیر نقشه ای را نشان می دهد که شامل چند خط مسیر، مبدا جدید (پین آبی روشن) و مکان های موجود در نتایج جستجو (پین های سبز) است. توجه کنید که چگونه همه نتایج در طول مسیر اما از سن ماتئو گذشته است:
تاریخ آخرین بهروزرسانی 2025-09-03 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-09-03 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eCombine routing summary calculations with search along a route to find places near a specific route with travel duration and distance included.\u003c/p\u003e\n"],["\u003cp\u003eText Search (New) with \u003ccode\u003esearchAlongRouteParameters\u003c/code\u003e and \u003ccode\u003esetRoutingSummariesIncluded(true)\u003c/code\u003e enables searching for places along a defined route polyline.\u003c/p\u003e\n"],["\u003cp\u003eResponses include routing summaries with two-leg trip times: origin to place and place to route destination.\u003c/p\u003e\n"],["\u003cp\u003eCustomize the search by specifying routing origin, travel mode, and route modifiers like avoiding tolls, influencing travel time and distance calculations.\u003c/p\u003e\n"],["\u003cp\u003eThe response provides travel duration and distance for each leg, but not the route itself; use the Routes API with origin, place, and destination for route calculation.\u003c/p\u003e\n"]]],[],null,["Combine routing summaries with search along route\n=================================================\n\nYou can combine **routing summary** calculations with **search along a route** .\nIn this case, [Text Search (New)](/maps/documentation/places/android-sdk/text-search) returns the travel duration and distance to each\nplace in the response, and then from each place to the final destination of the\nroute.\n\nTo use Text Search (New) to calculate the routing summary along with search\nalong a route:\n\n1. Use the Routes API to calculate a route that [returns a route polyline](/maps/documentation/routes/traffic_on_polylines)\n in the response.\n\n2. Use `searchAlongRouteParameters.setPolyline()` to\n pass the route polyline to Text Search (New) to bias the search results to\n the route. The response then contains places that match the search criteria\n and are also located near the specified route.\n\n3. When building the request object, add `.setRoutingSummariesIncluded(true)`.\n\nBy default, Text Search (New) performs the search along the entire route: \n\n```java\n// Define the route polyline object using the route string.\nEncodedPolyline encodedPolyline = EncodedPolyline.newInstance(\"wblcFptchVIFOd@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\n// Specify the list of fields to return.\nfinal List\u003cPlace.Field\u003e placeFields = Arrays.asList(Place.Field.ID, Place.Field.NAME);\n\n// Define the search along route parameters object and pass the polyline object.\nSearchAlongRouteParameters searchAlongRouteParameters = SearchAlongRouteParameters.builder()\n .setPolyline(encodedPolyline)\n .build();\n\n// Use the builder to create a SearchByTextRequest object and pass the search along route parameters.\nfinal SearchByTextRequest searchByTextRequest = SearchByTextRequest.builder(\"Spicy Vegetarian Food\", placeFields)\n .setMaxResultCount(10)\n .setSearchAlongRouteParameters(searchAlongRouteParameters)\n .setRoutingSummariesIncluded(true)\n .build();\n\n// Call PlacesClient.searchByText() to perform the search.\n// Define a response handler to process the returned List of Place objects.\nplacesClient.searchByText(searchByTextRequest) \n .addOnSuccessListener(response -\u003e {\n List\u003cPlace\u003e places = response.getPlaces();\n List\u003cRoutingSummary\u003e routingSummaries = response.getRoutingSummaries();\n List\u003cLeg\u003e legs = routingSummaries.get(0).getLegs();\n Duration duration = legs.get(0).getDuration();\n });\n```\n\n\nThe response contains objects that include lists of the requested places fields and routing\nsummaries containing the duration and distance to travel to each place.\nYou can call [`SearchByTextResponse.getRoutingSummaries()`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/SearchByTextResponse#getRoutingSummaries()) to return the list of routing summaries.\n\nFor each entry in the `legs` array, Text Search (New) returns a **two-leg** trip\ntime:\n\n- The first leg contains the travel duration and distance from the origin to\n the place.\n\n- The second leg contains the travel duration and distance from the place to\n the route destination.\n\n| **Note:** The response only contains the travel duration and duration for each leg. It does not contain the actual route itself. To calculate the route, pass the origin, location of the place as an intermediate waypoint, and the destination into the Routes API.\n\nSpecify the routing origin, travel mode, and route modifiers\n------------------------------------------------------------\n\nYou can modify the search and routing summary calculation by specifying the\nrouting origin, travel mode, route modifiers, and routing preferences. The\ntravel mode and route modifiers work the same as for calculating routing\nsummaries without specifying a route as shown in the [Specify travel\noptions](/maps/documentation/places/android-sdk/routing-summary#travel-options) topic.\n\nBy default, the first leg of each result contains the distance from the origin\ndefined by the polyline to each place. However, you can override that default by\nexplicitly specifying a routing origin in the request. If specified, the first\nleg of all responses specifies the distances and duration from the specified\nrouting origin, overriding the origin from the polyline.\n\nIn the next example, you specify a routing origin as the coordinates of San\nMateo, CA, specify to avoid tolls, and set the number of results to 5: \n\n```java\n// Define the route polyline object using the route string.\nEncodedPolyline encodedPolyline = EncodedPolyline.newInstance(\"wblcFptchVIFOd@G@EVw@Ms@dHKR}ApNA`AF~@Hf@TjAb@bBb@~@n@p@^Rd@~@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");\n\n// Specify the list of fields to return.\nfinal List\u003cPlace.Field\u003e placeFields = Arrays.asList(Place.Field.ID, Place.Field.NAME);\n\n// Define the routing modifiers object.\nRouteModifiers routeModifiers = RouteModifiers.builder()\n .setAvoidTolls(true)\n .build();\n\n// Define the routing parameters object and pass the routing origin.\n// Set the travel mode to DRIVE.\n// Pass the routeModifiers object.\nRoutingParameters routingParameters = RoutingParameters.builder()\n .setOrigin(toLatLng(\"37.56617, -122.30870\"))\n .setTravelMode(DRIVE)\n .setRouteModifiers(routeModifiers)\n .build();\n\n// Define the search along route parameters object and pass the polyline object.\nSearchAlongRouteParameters searchAlongRouteParameters = SearchAlongRouteParameters.builder()\n .setPolyline(encodedPolyline)\n .build();\n\n// Use the builder to create a SearchByTextRequest object and pass the search along route parameters.\nfinal SearchByTextRequest searchByTextRequest = SearchByTextRequest.builder(\"Spicy Vegetarian Food\", placeFields)\n .setMaxResultCount(5)\n .setRoutingParameters(routingParameters)\n .setSearchAlongRouteParameters(searchAlongRouteParameters)\n .setRoutingSummariesIncluded(true)\n .build();\n\n// Call PlacesClient.searchByText() to perform the search.\n// Define a response handler to process the returned List of Place objects.\nplacesClient.searchByText(searchByTextRequest) \n .addOnSuccessListener(response -\u003e {\n List\u003cPlace\u003e places = response.getPlaces();\n List\u003cRoutingSummary\u003e routingSummaries = result.getRoutingSummaries();\n List\u003cLeg\u003e legs = routingSummaries.get(0).getLegs();\n Duration duration = legs.get(0).getDuration();\n });\n```\n\nThe following image shows a map that contains the route polyline, the new origin\n(light-blue pin), and the places in the search results (green pins). Notice how\nall the results are along the route but past San Mateo:"]]