การย้ายข้อมูลช่องสถานที่ตั้ง (open_now, utc_offset)
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เราเลิกใช้งานฟิลด์สถานที่ opening_hours.open_now
และ utc_offset
ตั้งแต่วันที่ 20 พฤศจิกายน 2019 และจะปิดให้บริการในวันที่ 20 กุมภาพันธ์ 2021 ระบบเลิกใช้งานฟิลด์เหล่านี้ใน
Places Library, Maps JavaScript API เท่านั้น คู่มือนี้แสดงวิธีอัปเดตโค้ดเพื่อ
หยุดใช้ช่องเหล่านี้
opening_hours.open_now
ฟิลด์
ส่วนนี้จะแสดงวิธีอัปเดตฟังก์ชันการทำงานนี้สำหรับคำขอ Places แต่ละประเภท
คำขอรายละเอียดสถานที่
ช่อง opening_hours.open_now
จะแทนที่ด้วยเมธอด
opening_hours.isOpen()
สําหรับคําขอรายละเอียดสถานที่
แทนที่จะขอ opening_hours.open_now
ในพารามิเตอร์คำขอ fields
ให้ใส่ opening_hours
และ utc_offset_minutes
ในพารามิเตอร์คำขอ fields
จากนั้นเรียกใช้เมธอด opening_hours.isOpen()
ในออบเจ็กต์ google.maps.places.PlaceResult
ที่ส่งคืน
เพื่อตรวจสอบว่าสถานที่เปิดอยู่หรือไม่ ตัวอย่างต่อไปนี้แสดงคำขอรายละเอียดสถานที่ซึ่งระบุว่าสถานที่
เปิดอยู่หรือไม่
new google.maps.places.PlacesService(attrContainer).getDetails({
placeId: '...',
fields: ['opening_hours','utc_offset_minutes'],
}, function (place, status) {
if (status !== 'OK') return; // something went wrong
const isOpenAtTime = place.opening_hours.isOpen(new Date('December 17, 2020 03:24:00'));
if (isOpenAtTime) {
// We know it's open.
}
const isOpenNow = place.opening_hours.isOpen();
if (isOpenNow) {
// We know it's open.
}
});
คำขอ Find Place
สำหรับคำขอ Find Place
ไม่มีการแทนที่ฟิลด์ opening_hours.open_now
เราขอแนะนำให้ส่งคำขอรายละเอียดสถานที่
เพื่อรับข้อมูล opening_hours
คำขอการค้นหาในบริเวณใกล้เคียงและคำขอการค้นหาข้อความ
สำหรับคำขอ Nearby Search และ Text Search คุณสามารถใช้พารามิเตอร์คำขอ openNow
ซึ่งมีผลเป็นการกรองผลลัพธ์ให้รวมเฉพาะสถานที่ที่เปิดอยู่
ในขณะนี้
openNow:false
จะแสดงสถานที่ทั้งหมด
openNow:true
จะแสดงเฉพาะสถานที่ที่เปิดให้บริการอยู่ในขณะนี้
หากต้องการแสดงสถานที่ทั้งหมดและระบุสถานะ openNow
ให้ส่งคำขอก่อนโดยใช้
openNow:false
เพื่อรับสถานที่ทั้งหมด จากนั้นส่งคำขอโดยใช้ openNow:true
เพื่อ
รับเฉพาะสถานที่ที่เปิดอยู่ จากนั้นผสานคำตอบ
utc_offset
ฟิลด์
ในคำขอรายละเอียดสถานที่ utc_offset
จะแทนที่ด้วยฟิลด์
utc_offset_minutes
เพียงแทนที่อินสแตนซ์ของ utc_offset
ด้วย
utc_offset_minutes
ในfields
พารามิเตอร์คำขอ และเมื่ออ่านข้อมูลนี้จาก PlaceResult
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-27 UTC
[null,null,["อัปเดตล่าสุด 2025-08-27 UTC"],[[["\u003cp\u003eThe Places fields \u003ccode\u003eopening_hours.open_now\u003c/code\u003e and \u003ccode\u003eutc_offset\u003c/code\u003e are deprecated and will be turned off on February 20, 2021 in the Places Library, Maps JavaScript API.\u003c/p\u003e\n"],["\u003cp\u003eFor Place Details requests, use the \u003ccode\u003eopening_hours.isOpen()\u003c/code\u003e method and include \u003ccode\u003eopening_hours\u003c/code\u003e and \u003ccode\u003eutc_offset_minutes\u003c/code\u003e in the \u003ccode\u003efields\u003c/code\u003e request parameter instead of \u003ccode\u003eopening_hours.open_now\u003c/code\u003e and \u003ccode\u003eutc_offset\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eFor Find Place requests, it is recommended to make a Place Details request to get \u003ccode\u003eopening_hours\u003c/code\u003e information.\u003c/p\u003e\n"],["\u003cp\u003eFor Nearby Search and Text Search requests, use the \u003ccode\u003eopenNow\u003c/code\u003e request parameter to filter results based on open/closed status.\u003c/p\u003e\n"],["\u003cp\u003eReplace \u003ccode\u003eutc_offset\u003c/code\u003e with \u003ccode\u003eutc_offset_minutes\u003c/code\u003e in Place Details requests for the UTC offset information.\u003c/p\u003e\n"]]],[],null,["# Place Field Migration (open_now, utc_offset)\n\n\u003cbr /\u003e\n\nThe Places fields `opening_hours.open_now` and `utc_offset` are deprecated as\nof November 20, 2019, and will be turned off on\nFebruary 20, 2021. These fields are deprecated ONLY in the\nPlaces Library, Maps JavaScript API. This guide shows you how to update your code to\nstop using these fields.\n\n`opening_hours.open_now` field\n------------------------------\n\nThis section shows how to update this functionality for each type of Places\nrequest.\n\n### Place Details requests\n\nThe `opening_hours.open_now` field is replaced by the\n[`opening_hours.isOpen()`](/maps/documentation/javascript/reference/places-service#PlaceOpeningHours)\nmethod. \n\nFor [Place Details requests](/maps/documentation/javascript/places#place_details_requests),\ninstead of requesting `opening_hours.open_now` in the `fields` request\nparameter, include `opening_hours` and `utc_offset_minutes` in the `fields`\nrequest parameter, then call the `opening_hours.isOpen()` method on the returned\n`google.maps.places.PlaceResult` object to check whether the place is open. The\nfollowing example shows a Place Details request that determines whether a place\nis open: \n\n new google.maps.places.PlacesService(attrContainer).getDetails({\n placeId: '...',\n fields: ['opening_hours','utc_offset_minutes'],\n }, function (place, status) {\n if (status !== 'OK') return; // something went wrong\n const isOpenAtTime = place.opening_hours.isOpen(new Date('December 17, 2020 03:24:00'));\n if (isOpenAtTime) {\n // We know it's open.\n }\n\n const isOpenNow = place.opening_hours.isOpen();\n if (isOpenNow) {\n // We know it's open.\n }\n });\n\n### Find Place requests\n\nFor [Find Place requests](/maps/documentation/javascript/places#find_place_requests),\nthere is no replacement for the `opening_hours.open_now` field. We recommend\nmaking a [Place Details request](/maps/documentation/javascript/places#place_details_requests)\nto get `opening_hours` information.\n\n### Nearby Search \\& Text Search requests\n\nFor Nearby Search and Text Search requests, you can use the [`openNow`](/maps/documentation/javascript/reference/places-service#PlaceSearchRequest)\nrequest parameter, which has the effect of filtering results to include only\nplaces that are currently open.\n\n- `openNow:false` returns all places.\n- `openNow:true` returns only places that are currently open.\n\nTo list all places AND indicate `openNow` status, first make a request using\n`openNow:false` to get all places, then make a request using `openNow:true` to\nget open places only. Then, merge the responses.\n\n`utc_offset` field\n------------------\n\nIn Place Details requests, the `utc_offset` field is replaced by the\n`utc_offset_minutes` field. Simply replace occurrences of `utc_offset` with\n`utc_offset_minutes` in the `fields` request parameter, and when reading this\ninformation from `PlaceResult`."]]