How to Use Location AR with Code
Use VPS2 Site and asset localization for Location AR. Select a Site at runtime, call the platform's localize API with its Site ID, and place content relative to the asset that VPS2 localizes against.
The Site ID is the localization target. A localized asset ID is available only after visual localization succeeds; use the matching asset's tracking transform for AR placement. Do not use an anchor payload as the map identifier.
| Platform | Start localization | Read the asset pose |
|---|---|---|
| Swift | localize(siteId:) | assetTrackingData(assetId:) |
| Kotlin | localize(siteId) | getAssetTrackingData(assetId) |
| Unity | TryLocalize(...) | Use the localized asset tracking pose exposed by your installed NSDK version. |
You can instead call the latitude, longitude, and radius overload to find eligible Sites nearby. These requests are additive and asynchronous, so wait for a localized asset before trying to render map-relative content.
See Place virtual content with VPS2, Get started with Sites, and Geolocate with VPS2.