ตรวจสอบความพร้อมใช้งานของ VPS ที่ตำแหน่งปัจจุบันของอุปกรณ์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Geospatial API ใช้ข้อมูล VPS และ GPS ร่วมกันเพื่อสร้างตำแหน่งเชิงพื้นที่ที่มีความแม่นยำสูง API นี้ใช้ได้ในทุกที่ที่อุปกรณ์สามารถระบุตำแหน่งได้ ดังนี้
- ในพื้นที่ที่มีความแม่นยำของ GPS ต่ำ เช่น พื้นที่ในอาคารและสภาพแวดล้อมในเมืองที่หนาแน่น API จะอาศัยความครอบคลุมของ VPS เพื่อสร้างท่าทางที่มีความแม่นยำสูง
- ในสภาพแวดล้อมกลางแจ้งที่มีสิ่งกีดขวางเหนือศีรษะเพียงเล็กน้อยหรือไม่มีเลย Geospatial API อาจใช้ข้อมูลตำแหน่ง GPS ที่พร้อมใช้งานเพื่อสร้างตำแหน่งเชิงพื้นที่ที่มีความแม่นยำสูงได้
คุณสามารถระบุความพร้อมใช้งานของ VPS ในตำแหน่งแนวนอนที่ระบุได้ก่อนที่เซสชัน AR จะเริ่มขึ้น และใช้ข้อมูลดังกล่าวเพื่อสร้างประสบการณ์ที่เฉพาะเจาะจงมากขึ้น เช่น เพื่อแสดงปุ่ม "เข้าสู่ AR" เฉพาะเมื่อ VPS พร้อมใช้งานเท่านั้น
เปิดใช้ ARCore API
แอปของคุณต้องเปิดใช้ ARCore API เพื่อตรวจสอบความพร้อมใช้งานของ VPS
ตรวจสอบความพร้อมให้บริการของ VPS ในแอป
Geospatial API สามารถใช้ได้ทุกที่ที่อุปกรณ์ระบุตำแหน่งได้ หากประสบการณ์ AR ของคุณขึ้นอยู่กับความครอบคลุมของ VPS คุณสามารถใช้ AREarthManager.CheckVpsAvailabilityAsync()
เพื่อรับ VpsAvailabilityPromise
ซึ่งเป็นงานที่ทำงานแบบไม่พร้อมกันซึ่งจะตรวจสอบความพร้อมใช้งานของ VPS ในตำแหน่งแนวนอนที่ระบุ
เมื่อคุณมี VpsAvailabilityPromise
แล้ว คุณจะดูผลลัพธ์ได้โดยการลงคะแนนเสียง
สำรวจผลลัพธ์
ใช้ VpsAvailabilityPromise.State
เพื่อดูสถานะของ InterruptiblePromise
โดยสถานะมี 3 สถานะดังนี้
คุณสามารถตรวจสอบ VpsAvailabilityPromise.State
ต่อไปได้จนกว่างานจะเสร็จสมบูรณ์
ยกเลิก InterruptiblePromise
ใช้ VpsAvailabilityPromise.Cancel()
เพื่อพยายามยกเลิก InterruptiblePromise
เนื่องจากการขนานของชุดข้อความ คุณจึงอาจยกเลิกไม่สำเร็จ
ใช้ Geospatial API ที่ไม่มีความครอบคลุมของ VPS
นอกจากนี้ คุณยังใช้ Geospatial API ในพื้นที่ที่ไม่มี VPS ครอบคลุมได้ด้วย ในสภาพแวดล้อมกลางแจ้งที่มีสิ่งกีดขวางเหนือศีรษะเพียงเล็กน้อยหรือไม่มีเลย GPS อาจเพียงพอที่จะสร้างท่าทางที่มีความแม่นยำสูง
ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-14 UTC
[null,null,["อัปเดตล่าสุด 2025-07-14 UTC"],[[["\u003cp\u003eThe Geospatial API leverages VPS and GPS data to create highly accurate location anchors, enabling augmented reality experiences in diverse environments.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can check VPS availability before an AR session begins, optimizing user experience by prompting interactions only when VPS is available.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eAREarthManager.CheckVpsAvailabilityAsync()\u003c/code\u003e allows developers to determine VPS availability at a specific location, which can be polled for its status and potentially cancelled.\u003c/p\u003e\n"],["\u003cp\u003eEven without VPS coverage, the Geospatial API can utilize GPS data in outdoor settings with clear skies to achieve accurate pose estimation.\u003c/p\u003e\n"],["\u003cp\u003eAfter confirming VPS availability or GPS suitability, developers can proceed to obtain the device's Geospatial pose, anchoring AR content to real-world locations.\u003c/p\u003e\n"]]],[],null,["# Check VPS availability at the device's current location\n\n\u003cbr /\u003e\n\nThe Geospatial API uses a combination of [VPS](/ar/develop/geospatial#global_localization_with_vps) and GPS data to generate high-accuracy Geospatial poses. The API can be used in any place where the device is able to determine its location:\n\n- In areas with low GPS accuracy, such as indoor spaces and dense urban environments, the API will rely on VPS coverage to generate high-accuracy poses.\n- In outdoor environments with few or no overhead obstructions, the Geospatial API may be able to use available GPS location data to generate Geospatial poses with high accuracy.\n\nYou can determine VPS availability at a given horizontal position before the AR session starts and use it to create more specific experiences --- for example, to present an \"Enter AR\" button only when VPS is available.\n\nEnable the ARCore API\n---------------------\n\nYour app must enable the [ARCore API](/ar/develop/unity-arf/geospatial/enable#enable_the_arcore_api) to check VPS availability.\n\nCheck VPS availability in your app\n----------------------------------\n\nThe Geospatial API can be used in any place where the device is able to determine its location. If your AR experience hinges on VPS coverage, you can use [`AREarthManager.CheckVpsAvailabilityAsync()`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#checkvpsavailabilityasync) to obtain a [`VpsAvailabilityPromise`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/VpsAvailabilityPromise), an asynchronous task that checks the VPS availability at a given horizontal position.\n\nOnce you have the [`VpsAvailabilityPromise`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/VpsAvailabilityPromise), you can obtain its result by polling.\n\n\n### Poll the result\n\nUse [`VpsAvailabilityPromise.State`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/VpsAvailabilityPromise#state) to obtain the state of the `InterruptiblePromise`. There are three different states:\n\n- [`Pending`](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate): The operation is not yet complete, so no result is known.\n- [`Cancelled`](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate): The operation has been cancelled by [`VpsAvailabilityPromise.Cancel()`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/VpsAvailabilityPromise#cancel). Any registered callback will never be called.\n- [`Done`](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate): The operation is complete. Use [`VpsAvailabilityPromise.Result`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/VpsAvailabilityPromise#result) to obtain the result.\n\nYou may continue checking [`VpsAvailabilityPromise.State`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/VpsAvailabilityPromise#state) until the task is complete.\n\nCancel the `InterruptiblePromise`\n---------------------------------\n\nUse [`VpsAvailabilityPromise.Cancel()`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/VpsAvailabilityPromise#cancel) to attempt to cancel the `InterruptiblePromise`. Due to thread parallelism, it may be possible that your cancel attempt does not actually succeed.\n\n\nUse the Geospatial API without VPS coverage\n-------------------------------------------\n\nThe Geospatial API can also be used in areas that do not have VPS coverage. In outdoor environments with few or no overhead obstructions, GPS may be sufficient to generate a pose with high accuracy.\n\nWhat's next\n-----------\n\n- [Obtain the device camera's Geospatial pose](/ar/develop/unity-arf/geospatial/obtain-device-pose) to determine the exact location of the user's device in the real world."]]