ย้ายข้อมูลไปยังการเติมข้อความอัตโนมัติ (ใหม่)
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
นักพัฒนาแอปในเขตเศรษฐกิจยุโรป (EEA)
บทนำ
Places API รองรับ API Place Autocomplete (เดิม)
และ Query Autocomplete (เดิม)
หากคุณคุ้นเคยกับ API เหล่านี้ ฟีเจอร์เติมข้อความอัตโนมัติ (ใหม่) จะทำการเปลี่ยนแปลงต่อไปนี้
- การเติมข้อความอัตโนมัติ (ใหม่) ใช้คำขอ HTTP POST ส่งพารามิเตอร์ใน
เนื้อหาคำขอหรือในส่วนหัวโดยเป็นส่วนหนึ่งของคำขอ HTTP POST ในทางตรงกันข้าม
เมื่อใช้ API เดิม คุณจะส่งพารามิเตอร์ URL โดยใช้
คำขอ HTTP GET
- การเติมข้อความอัตโนมัติ (ใหม่) รองรับทั้งคีย์ API
และโทเค็น OAuth เป็นกลไกการตรวจสอบสิทธิ์
- การเติมข้อความอัตโนมัติ (ใหม่) รองรับเฉพาะ JSON เป็นรูปแบบการตอบกลับ
ตารางต่อไปนี้แสดงพารามิเตอร์ใน Place Autocomplete (เดิม) และ Query Autocomplete (เดิม) ที่มีการเปลี่ยนชื่อหรือแก้ไขสำหรับ Autocomplete (ใหม่) หรือพารามิเตอร์ที่ระบบไม่รองรับอีกต่อไป
พารามิเตอร์ปัจจุบัน |
พารามิเตอร์ใหม่ |
หมายเหตุ |
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 ตัวอย่างต่อไปนี้ใช้ Place Autocomplete (เดิม) ในตัวอย่างนี้ คุณขอการตอบกลับ JSON ที่มีข้อมูลเกี่ยวกับสถานที่ที่ชื่อ "Amoeba" ซึ่งเป็นประเภท 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
ไม่จำเป็นต้องใช้ FieldMask สำหรับคำขอเติมข้อความอัตโนมัติ (ใหม่) แต่สามารถใช้เพื่อกรองผลลัพธ์ที่เฉพาะเจาะจงในคำตอบได้ ตัวอย่างเช่น คำขอต่อไปนี้ใช้มาสก์ฟิลด์เพื่อให้การตอบกลับมีเฉพาะ suggestions.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
ดูข้อมูลเพิ่มเติมเกี่ยวกับการใช้ FieldMask ได้ที่รายละเอียดสถานที่ (ใหม่)
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-29 UTC
[null,null,["อัปเดตล่าสุด 2025-08-29 UTC"],[],[],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)."]]