مقدمه
Places API (Legacy) supports Text Search (Legacy) . If you are familiar with Text Search (Legacy), Text Search (New) makes the following changes:
- جستجوی متن (جدید) از درخواستهای HTTP POST استفاده میکند. پارامترها را در بدنه درخواست یا در هدرها به عنوان بخشی از یک درخواست HTTP POST ارسال کنید. در مقابل، با جستجوی متن (قدیمی)، پارامترهای URL را با استفاده از یک درخواست HTTP GET ارسال میکنید.
- ماسک کردن فیلد الزامی است. شما باید مشخص کنید که میخواهید کدام فیلدها در پاسخ برگردانده شوند. هیچ لیست پیشفرضی از فیلدهای برگردانده شده وجود ندارد. اگر این لیست را حذف کنید، متدها خطا برمیگردانند. برای اطلاعات بیشتر، به FieldMask مراجعه کنید.
- Text Search (New) supports both API keys and OAuth tokens as the authentication mechanism.
- Only JSON is supported as a response format in Text Search (New).
Text Search (Legacy) lets you specify latitude and longitude coordinates in the query string. For example:
query=37.4239,-122.0925. That option is not supported in Text Search (New).Use Reverse Geocoding to search on coordinates and return an address, or Nearby Search (New) to find places around a certain location.
- The JSON response format for Text Search (New) has changed from the format of the legacy APIs. For more details, see Migrate the Places API response .
The following table lists parameters in Text Search (Legacy) that have been renamed or modified for Text Search (New), or parameters that are no longer supported.
| پارامتر فعلی | پارامتر جدید | Notes |
|---|---|---|
evOptions | پارامتر جدید. | |
language | languageCode | |
location | locationBias | |
maxprice/minprice | priceLevels | |
opennow | openNow | |
pagetoken | pageToken | |
query | textQuery | Required in all requests. |
radius | locationBias | Specify the radius when defining a locationBias . |
region | regionCode | |
type | includedType | Only takes a single value. |
strictTypeFiltering | پارامتر جدید. |
درخواست نمونه
The following example GET request uses Text Search (Legacy). In this example, you request a JSON response containing information about "Spicy Vegetarian Food in Sydney, Australia" and pass all parameters as URL parameters:
curl -L -X GET \ 'https://maps.googleapis.com/maps/api/place/textsearch/json?query=Spicy%20Vegetarian%20Food%20in%20Sydney%20Australia&key=API_KEY
با جستجوی متنی (جدید)، شما یک درخواست POST ارسال میکنید و تمام پارامترها را در بدنه درخواست JSON یا در هدرها به عنوان بخشی از درخواست POST ارسال میکنید. این مثال همچنین از یک ماسک فیلد استفاده میکند، بنابراین پاسخ فقط شامل نام نمایشی و آدرس قالببندی شده مکان است:
curl -X POST -d '{
"textQuery" : "Spicy Vegetarian Food in Sydney, Australia"
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \
-H 'X-Goog-FieldMask: places.displayName,places.formattedAddress' \
'https://places.googleapis.com/v1/places:searchText'