ย้ายข้อมูลไปยังการค้นหาข้อความ (ใหม่)
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
นักพัฒนาแอปในเขตเศรษฐกิจยุโรป (EEA)
บทนำ
Places API (เดิม) รองรับการค้นหาข้อความ (เดิม) หากคุณคุ้นเคยกับ
การค้นหาข้อความ (เดิม)
การค้นหาข้อความ (ใหม่)
จะทำการเปลี่ยนแปลงต่อไปนี้
- การค้นหาข้อความ (ใหม่) ใช้คำขอ HTTP POST ส่งพารามิเตอร์ในเนื้อหาคำขอหรือในส่วนหัวโดยเป็นส่วนหนึ่งของคำขอ HTTP POST
ในทางตรงกันข้าม เมื่อใช้การค้นหาข้อความ (เดิม) คุณจะส่งพารามิเตอร์ URL โดยใช้คำขอ HTTP GET
- ต้องมีการมาสก์ฟิลด์ คุณต้องระบุช่องที่ต้องการให้แสดงผล
ในการตอบกลับ ไม่มีรายการฟิลด์ที่แสดงผลเริ่มต้น หากคุณละเว้น
รายการนี้ เมธอดจะแสดงข้อผิดพลาด ดูข้อมูลเพิ่มเติมได้ที่
FieldMask
- การค้นหาข้อความ (ใหม่) รองรับทั้งคีย์ API
และโทเค็น OAuth เป็นกลไกการตรวจสอบสิทธิ์
- การค้นหาข้อความ (ใหม่) รองรับเฉพาะ JSON เป็นรูปแบบการตอบกลับ
การค้นหาข้อความ (เดิม) ช่วยให้คุณระบุพิกัดละติจูดและลองจิจูด
ในสตริงการค้นหาได้ ตัวอย่างเช่น query=37.4239,-122.0925
ตัวเลือกดังกล่าวไม่รองรับใน Text Search (ใหม่)
ใช้
การแปลงพิกัดทางภูมิศาสตร์ย้อนกลับ
เพื่อค้นหาพิกัดและแสดงที่อยู่ หรือ
การค้นหาใกล้เคียง (ใหม่)
เพื่อค้นหาสถานที่รอบๆ ตำแหน่งที่ตั้งหนึ่งๆ
- รูปแบบการตอบกลับ JSON สำหรับการค้นหาข้อความ (ใหม่)
มีการเปลี่ยนแปลงจากรูปแบบของ API เดิม ดูรายละเอียดเพิ่มเติมได้ที่
ย้ายข้อมูลการตอบกลับของ Places API
ตารางต่อไปนี้แสดงพารามิเตอร์ใน Text Search (เดิม) ที่มีการเปลี่ยนชื่อหรือแก้ไขสำหรับ Text Search (ใหม่) หรือพารามิเตอร์ที่ระบบไม่รองรับอีกต่อไป
พารามิเตอร์ปัจจุบัน |
พารามิเตอร์ใหม่ |
หมายเหตุ |
|
evOptions |
พารามิเตอร์ใหม่ |
language |
languageCode |
|
location |
locationBias |
|
maxprice/minprice |
priceLevels |
|
opennow |
openNow |
|
pagetoken |
pageToken |
|
query |
textQuery |
ต้องระบุในคำขอทั้งหมด |
radius |
locationBias |
ระบุรัศมีเมื่อกำหนด locationBias |
region |
regionCode |
|
type |
includedType |
รับได้เพียงค่าเดียว |
|
strictTypeFiltering |
พารามิเตอร์ใหม่ |
ตัวอย่างคำขอ
คำขอ GET ตัวอย่างต่อไปนี้ใช้การค้นหาข้อความ (เดิม) ในตัวอย่างนี้ คุณ
ขอการตอบกลับ JSON ที่มีข้อมูลเกี่ยวกับ "อาหารมังสวิรัติรสเผ็ดใน
ซิดนีย์ ออสเตรเลีย" และส่งพารามิเตอร์ทั้งหมดเป็นพารามิเตอร์ของ URL
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'
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-29 UTC
[null,null,["อัปเดตล่าสุด 2025-08-29 UTC"],[],[],null,["# Migrate to Text Search (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 (Legacy) supports\n[Text Search (Legacy)](/maps/documentation/places/web-service/legacy/search-text). If you are familiar with\nText Search (Legacy),\n[Text Search (New)](/maps/documentation/places/web-service/text-search)\nmakes the following changes:\n\n- Text Search (New) uses HTTP POST requests. Pass parameters in the request body or in headers as part of an HTTP POST request. In contrast, with Text Search (Legacy), you pass URL parameters using an HTTP GET request.\n- Field masking is required. You must specify which fields you want returned in the response. There is no default list of returned fields. If you omit this list, the methods return an error. For more information, see [FieldMask](/maps/documentation/places/web-service/text-search#fieldmask).\n- Text Search (New) supports both [API keys](/maps/documentation/places/web-service/legacy/get-api-key) and [OAuth](/maps/documentation/places/web-service/legacy/oauth-token) tokens as the authentication mechanism.\n- Only JSON is supported as a response format in Text Search (New).\n- Text Search (Legacy) lets you specify latitude and longitude\n coordinates in the query string. For example: `query=37.4239,-122.0925`.\n That option is not supported in Text Search (New).\n\n Use\n [Reverse Geocoding](/maps/documentation/geocoding/requests-reverse-geocoding)\n to search on coordinates and return an address, or\n [Nearby Search (New)](/maps/documentation/places/web-service/nearby-search)\n to find places around a certain location.\n- 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](/maps/documentation/places/web-service/migrate-response).\n\nThe following table lists parameters in Text Search (Legacy) that have been\nrenamed or modified for Text Search (New), or parameters that are no\nlonger supported.\n\n| Current parameter | New parameter | Notes |\n|---------------------|-----------------------|----------------------------------------------------|\n| | `evOptions` | New parameter. |\n| `language` | `languageCode` | |\n| `location` | `locationBias` | |\n| `maxprice/minprice` | `priceLevels` | |\n| `opennow` | `openNow` | |\n| `pagetoken` | `pageToken` | |\n| `query` | `textQuery` | Required in all requests. |\n| `radius` | `locationBias` | Specify the radius when defining a `locationBias`. |\n| `region` | `regionCode` | |\n| `type` | `includedType` | Only takes a single value. |\n| | `strictTypeFiltering` | New parameter. |\n\nExample request\n---------------\n\nThe following example GET request uses Text Search (Legacy). In this example, you\nrequest a JSON response containing information about \"Spicy Vegetarian Food in\nSydney, Australia\" and pass all parameters as URL parameters: \n\n```curl\ncurl -L -X GET \\\n'https://maps.googleapis.com/maps/api/place/textsearch/json?query=Spicy%20Vegetarian%20Food%20in%20Sydney%20Australia&key=API_KEY\n```\n\nWith Text Search (New), you make a POST request and pass all parameters in\nthe JSON request body or in headers as part of the POST request. This example\nalso uses a field mask so the response only includes the display name and\nformatted address of the place: \n\n```\ncurl -X POST -d '{\n \"textQuery\" : \"Spicy Vegetarian Food in Sydney, Australia\"\n}' \\\n-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \\\n-H 'X-Goog-FieldMask: places.displayName,places.formattedAddress' \\\n'https://places.googleapis.com/v1/places:searchText'\n```"]]