קבלת המיקום הגיאו-מרחבי של מצלמת המכשיר
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אחרי שמגדירים את ההגדרות של האפליקציה כך שישתמשו ב-Geospatial API, אפשר לקבל את AREarthManager.CameraGeospatialPose
של מצלמת המכשיר. התנוחה הזו, שמנוהלת באובייקט AREarthManager
, מכילה את הפרטים הבאים:
- מיקום, שמוצג לפי קו רוחב וקו אורך
- גובה
- כיוון שמשוער לכיוון שאליו המשתמש פונה במערכת הקואורדינטות EUS, כאשר X+ מצביע לכיוון מזרח, Y+ מצביע למעלה ו-Z+ מצביע לכיוון דרום
בדיקת סטטוס המעקב
ערכים גיאו-מרחביים תקפים רק כאשר הערך של AREarthManager.EarthTrackingState
הוא TrackingState.Tracking
. חשוב לתחום את כל הקריאות ל-Geospatial API בבלוק בקרה מסוג AREarthManager.EarthTrackingState
.
var earthTrackingState = EarthManager.EarthTrackingState;
if (earthTrackingState == TrackingState.Tracking)
{
// camera_geospatial_pose contains geodetic location, rotation, and
// confidences values.
var cameraGeospatialPose = EarthManager.CameraGeospatialPose;
}
אם AREarthManager.EarthTrackingState
לא הופך ל-TrackingState.Tracking
, הערך של AREarthManager.EarthTrackingState
עשוי להיות TrackingState.Limited
או TrackingState.None
. אם אף אחד מהתנאים האלה לא מתקיים, בודקים את השדה TrackingState.EarthTrackingState
, שבו מוצגים מצבי שגיאה אחרים שעשויים למנוע את המעקב אחרי האובייקט AREarthManager
.
שינוי התנוחה כדי לשפר את הדיוק
כשהמכשיר זקוף בכיוון ברירת המחדל, זוויות ההטיה (X+) והרוטציה (Z+) נוטות להיות מדויקות בגלל ההתאמה הטבעית למעקב AR. עם זאת, זוויות ההטיה (Y+) עשויות להשתנות בהתאם לזמינות הנתונים של ה-VPS ולתנאים הזמניים במיקום. יכול להיות שתצטרכו לבצע שינויים באפליקציה כדי לשפר את הדיוק.
GeospatialPose.OrientationYawAccuracy
מספק הערכת דיוק לזוויות ההטיה (Y+) של AREarthManager.CameraGeospatialPose
מסוים. הדיוק של כיוון הנטייה (yaw) הוא מספר שמתאר את הרדיוס, במעלות, של רמת הסמך ב-68% ביחס לזוויות הנטייה ב-GeospatialPose.EunRotation
. במילים אחרות, יש 68% סיכוי שזווית הנטייה האמיתית של AREarthManager.CameraGeospatialPose
מדויקת בטווח של מספר המעלות שמוחזר על ידי GeospatialPose.OrientationYawAccuracy
.
ככל שהערך גבוה יותר, כך רמת הדיוק נמוכה יותר. לדוגמה, אם זווית ההטיה המשוערת היא 60 מעלות ורמת הדיוק של ההטיה היא 10 מעלות, יש 68% סבירות שזווית ההטיה האמיתית היא בין 50 ל-70 מעלות.
המאמרים הבאים
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-14 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-14 (שעון UTC)."],[[["\u003cp\u003eAccess the device camera's geospatial pose, including location, altitude, and orientation, using the \u003ccode\u003eAREarthManager.CameraGeospatialPose\u003c/code\u003e after configuring the Geospatial API.\u003c/p\u003e\n"],["\u003cp\u003eEnsure the \u003ccode\u003eAREarthManager.EarthTrackingState\u003c/code\u003e is in the \u003ccode\u003eTrackingState.Tracking\u003c/code\u003e state before using geospatial values to avoid issues caused by limited or no tracking.\u003c/p\u003e\n"],["\u003cp\u003eAccount for potential inaccuracies in the yaw (Y+) angle of the orientation, especially when the device isn't upright, and utilize \u003ccode\u003eGeospatialPose.OrientationYawAccuracy\u003c/code\u003e to estimate the yaw accuracy.\u003c/p\u003e\n"],["\u003cp\u003eUnderstand that the \u003ccode\u003eGeospatialPose.OrientationYawAccuracy\u003c/code\u003e value represents the radius, in degrees, of the 68th percentile confidence level around the yaw angles, with larger values indicating lower accuracy.\u003c/p\u003e\n"]]],[],null,["# Obtain the device camera's Geospatial pose\n\nOnce you have configured your app's settings to use the Geospatial API, you can obtain the device camera's [`AREarthManager.CameraGeospatialPose`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#camerageospatialpose). This pose, managed in an [`AREarthManager`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager) object, contains the following information:\n\n- Location, expressed in latitude and longitude\n- Altitude\n- An orientation approximating the direction the user is facing in the EUS coordinate system with X+ pointing east, Y+ pointing up, and Z+ pointing south\n\nCheck the tracking state\n------------------------\n\nGeospatial values are only valid while [`AREarthManager.EarthTrackingState`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#earthtrackingstate) is [`TrackingState.Tracking`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html). Make sure to wrap all Geospatial API calls in a [`AREarthManager.EarthTrackingState`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#earthtrackingstate) control block. \n\n var earthTrackingState = EarthManager.EarthTrackingState;\n if (earthTrackingState == TrackingState.Tracking)\n {\n // camera_geospatial_pose contains geodetic location, rotation, and\n // confidences values.\n var cameraGeospatialPose = EarthManager.CameraGeospatialPose;\n }\n\nIf [`AREarthManager.EarthTrackingState`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#earthtrackingstate) does not become [`TrackingState.Tracking`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html), [`AREarthManager.EarthTrackingState`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#earthtrackingstate) may be [`TrackingState.Limited`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html) or [`TrackingState.None`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html). If neither of these conditions are true, check [`TrackingState.EarthTrackingState`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#earthtrackingstate), which shows other error states that may keep the [`AREarthManager`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager) object from tracking.\n\nAdjust the pose for accuracy\n----------------------------\n\nWhen the device is upright in the default orientation, the pitch (X+) and roll (Z+) angles tend to be precise due to a natural alignment with AR tracking. However, the yaw (Y+) angles can vary depending on VPS data availability and temporal conditions at the location. Your app may have to make adjustments for accuracy.\n\n[`GeospatialPose.OrientationYawAccuracy`](/ar/reference/unity-arf/struct/Google/XR/ARCoreExtensions/GeospatialPose#orientationyawaccuracy) provides an accuracy estimate for the yaw (Y+) angles for a certain [`AREarthManager.CameraGeospatialPose`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#camerageospatialpose). The orientation yaw accuracy is a number that describes the radius, in degrees, of the 68th percentile confidence level around the yaw angles in [`GeospatialPose.EunRotation`](/ar/reference/unity-arf/struct/Google/XR/ARCoreExtensions/GeospatialPose#eunrotation). In other words, there is a 68% chance that the [`AREarthManager.CameraGeospatialPose`](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/AREarthManager#camerageospatialpose)'s true yaw angle is accurate within the number of degrees returned by\n[`GeospatialPose.OrientationYawAccuracy`](/ar/reference/unity-arf/struct/Google/XR/ARCoreExtensions/GeospatialPose#orientationyawaccuracy).\n\nLarger values indicate lower accuracy. For example, if the estimated yaw angle is 60 degrees and the yaw accuracy is 10 degrees, then there is a 68% probability that the true yaw angle is between 50 and 70 degrees.\n\nWhat's next\n-----------\n\n- [Place a Geospatial anchor](/ar/develop/unity-arf/geospatial/anchors#wgs84_anchors) by obtaining the anchor's Geospatial pose."]]