انتقال به تکمیل خودکار (جدید)
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
توسعه دهندگان منطقه اقتصادی اروپا (EEA). مقدمه
Places API از APIهای تکمیل خودکار مکان (میراث) و تکمیل خودکار درخواست (میراث) پشتیبانی می کند. اگر با این API ها آشنایی دارید، تکمیل خودکار (جدید) تغییرات زیر را ایجاد می کند:
- تکمیل خودکار (جدید) از درخواستهای HTTP POST استفاده میکند. پارامترها را در بدنه درخواست یا در هدرها به عنوان بخشی از درخواست HTTP POST ارسال کنید. در مقابل، با APIهای قدیمی، پارامترهای URL را با استفاده از درخواست HTTP GET ارسال می کنید.
- تکمیل خودکار (جدید) از کلیدهای API و نشانههای OAuth به عنوان مکانیزم احراز هویت پشتیبانی میکند.
- فقط JSON به عنوان فرمت پاسخ در تکمیل خودکار (جدید) پشتیبانی میشود.
جدول زیر پارامترهایی را در Place Autocomplete (Legacy) و Query Autocomplete (Legacy) که برای تکمیل خودکار (جدید) تغییر نام داده یا اصلاح شده اند یا پارامترهایی که دیگر پشتیبانی نمی شوند را فهرست می کند.
پارامتر فعلی | پارامتر جدید | یادداشت ها |
---|
components | includedRegionCodes | |
language | languageCode | |
location | locationBias | |
ipbias | | اگر هم locationBias و هم locationRestriction حذف کنید، API به طور پیشفرض از بایاس IP استفاده میکند. |
offset | inputOffset | |
radius | locationBias یا locationRestriction | |
region | regionCode | |
stricbounds | locationRestriction | |
sessiontoken | sessionToken | |
types | includedPrimaryTypes | |
درخواست نمونه
مثال زیر درخواست GET از تکمیل خودکار مکان (میراث) استفاده می کند. در این مثال، شما یک پاسخ JSON حاوی اطلاعاتی درباره مکانهایی به نام «آمیب» درخواست میکنید که از نوع establishment
هستند و همه پارامترها را به عنوان پارامترهای URL ارسال میکنند:
curl -L -X GET 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=amoeba&types=establishment&location=37.76999%2C-122.44696&radius=500&key=YOUR_API_KEY'
با تکمیل خودکار (جدید)، شما یک درخواست POST ایجاد می کنید و تمام پارامترها را در بدنه درخواست JSON یا در هدرها به عنوان بخشی از درخواست POST ارسال می کنید.
ماسک فیلد برای درخواست های تکمیل خودکار (جدید) مورد نیاز نیست، اما می توان از آنها برای فیلتر کردن نتایج خاص در پاسخ استفاده کرد. به عنوان مثال، درخواست زیر از یک فیلد ماسک استفاده می کند، بنابراین پاسخ فقط شامل suggestions.placePrediction.text
placePrediction.text است:
curl -X POST -d '{
"input": "Amoeba",
"locationBias": {
"circle": {
"center": {
"latitude": 37.76999,
"longitude": -122.44696
},
"radius": 500.0
}
}
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \
-H 'X-Goog-FieldMask: suggestions.placePrediction.text' \
https://places.googleapis.com/v1/places:autocomplete
برای کسب اطلاعات بیشتر در مورد استفاده از ماسک های میدانی، به جزئیات مکان (جدید) مراجعه کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Migrate to Autocomplete (New)\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nIntroduction\n------------\n\nPlaces API supports the\n[Place Autocomplete (Legacy)](/maps/documentation/places/web-service/autocomplete)\nand [Query Autocomplete (Legacy)](/maps/documentation/places/web-service/query) APIs.\nIf you are familiar with these APIs, Autocomplete (New) makes the following changes:\n\n- Autocomplete (New) uses HTTP POST requests. Pass parameters in the request body or in headers as part of an HTTP POST request. In contrast, with the legacy APIs, you pass URL parameters using an HTTP GET request.\n- Autocomplete (New) supports both [API keys](/maps/documentation/places/web-service/get-api-key) and [OAuth](/maps/documentation/places/web-service/oauth-token) tokens as the authentication mechanism.\n- Only JSON is supported as a response format in Autocomplete (New).\n\nThe following table lists parameters in Place Autocomplete (Legacy) and Query Autocomplete (Legacy) that have been renamed or modified for Autocomplete (New), or parameters that are no longer supported.\n\n| Current parameter | New parameter | Notes |\n|-------------------|-----------------------------------------|-----------------------------------------------------------------------------------------------------|\n| `components` | `includedRegionCodes` | |\n| `language` | `languageCode` | |\n| `location` | `locationBias` | |\n| `ipbias` | | If you omit both `locationBias` and `locationRestriction`, then the API uses IP biasing by default. |\n| `offset` | `inputOffset` | |\n| `radius` | `locationBias` or `locationRestriction` | |\n| `region` | `regionCode` | |\n| `stricbounds` | `locationRestriction` | |\n| `sessiontoken` | `sessionToken` | |\n| `types` | `includedPrimaryTypes` | |\n\nExample request\n---------------\n\nThe following example GET request uses Place Autocomplete (Legacy). In this\nexample, you request a JSON response containing information about places called\n\"Amoeba\" that are of type `establishment` and pass all parameters as URL\nparameters: \n\n```curl\ncurl -L -X GET 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=amoeba&types=establishment&location=37.76999%2C-122.44696&radius=500&key=YOUR_API_KEY'\n```\n\nWith Autocomplete (New), you make a POST request and pass all parameters\nin the JSON request body or in headers as part of the POST request.\n\nField masks are not required for Autocomplete (New) requests, but they can\nbe used to filter for specific results in the response. For example, the\nfollowing request uses a field mask so the response only includes the\n`suggestions.placePrediction.text` of the suggestion: \n\n```curl\ncurl -X POST -d '{\n \"input\": \"Amoeba\",\n \"locationBias\": {\n \"circle\": {\n \"center\": {\n \"latitude\": 37.76999,\n \"longitude\": -122.44696\n },\n \"radius\": 500.0\n }\n }\n}' \\\n-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \\\n-H 'X-Goog-FieldMask: suggestions.placePrediction.text' \\\nhttps://places.googleapis.com/v1/places:autocomplete\n```\n\nTo learn more about using field masks, see\n[Place Details (New)](/maps/documentation/places/web-service/place-details#fieldmask)."]]