Skip to main content
Version: 1.x

VPS ARKit Location Source

Provide accurate indoor positioning from the device camera using ARKit.

Overview​

The VPS (Visual Positioning System) Location Source recognizes the user's surroundings from the camera and reports an accurate indoor position through the Wemap LocationSource interface. It can drive WemapMapSDK / WemapGeoARSDK, or run standalone with a third-party map/AR system.

Important

Wemap VPS must be configured for your map by the Wemap team. Contact us if you are interested.

Requirements​

In addition to the common requirements (see Getting Started with Wemap SDKs), the device must support ARKit. Check at runtime:

guard VPSARKitLocationSource.isAvailable else {
// explain to the user that their device is not supported
return
}

You can also require ARKit at install time via UIRequiredDeviceCapabilities in your Info.plist.

Permissions​

VPS requires camera access. Declare NSCameraUsageDescription in your Info.plist and request permission before creating the source:

<key>NSCameraUsageDescription</key>
<string>Camera is used to understand your surroundings and provide accurate indoor navigation</string>

Known limitations​

ARKit relative positioning can drift or jump. Quality falls with device temperature and in visually sparse surroundings — a corridor of plain white walls is the usual example — and the SDK's overlays reduce that without removing it.

note

Relative positioning may be unreliable on iPhone SE (3rd generation).

Setting up the source​

Create a VPSARKitLocationSource from your session, then assign it to the map and/or AR view:

func setUpLocationSource(session: CoreSession) throws {
let vps = try VPSARKitLocationSource(session: session, config: VPSConfig())

// WemapMapSDK
mapView.userLocationManager.locationSource = vps

// and/or WemapGeoARSDK
arView.locationManager.locationSource = vps
}

To use VPS with a third-party map/AR, call start() and observe the inherited LocationSource coordinate/attitude streams directly.

Handling state and scanning​

Observe states and scanStatuses to guide the user, and call startScan() to let them scan their environment:

let states = vps.states
Task {
for await state in states {
// .notPositioning → prompt the user to scan with startScan()
// .accuratePositioning → hide hints; location updates begin
// .degradedPositioning → suggest (but don't force) a re-scan
}
}

vps.startScan()

The system may also start a background scan on its own (based on distance travelled, time since the last scan, or changing conditions). Observe backgroundScanStatuses to surface a subtle hint when appropriate.

While a scan runs, scanIssues tells you what keeps it from using the camera, for as long as it lasts: show the matching hint when it changes to an issue, and hide it when it changes back to .none. Today the one issue is .devicePointedTooLow, the phone pointing at the ground. Keep an @unknown default branch: later releases may add issues. Problems ARKit reports itself, such as too little light or too much motion, are on cameraTrackingStates.

let scanIssues = vps.scanIssues
Task {
for await issue in scanIssues {
// show "Hold the phone straight in front of you" while issue == .devicePointedTooLow
}
}

Map matching (assigning an itinerary)​

Assigning the followed itinerary to itinerary improves the experience (projections, conveyor detection, re-scan prompts). With WemapMapSDK/WemapGeoARSDK this is handled for you; standalone, assign it yourself:

let origin = Coordinate(coordinate2D: .init(latitude: 48.88007462, longitude: 2.35591097), levels: .single(0))
let destination = Coordinate(coordinate2D: .init(latitude: 48.88141308, longitude: 2.35747255), levels: .single(-2))

let itineraries = try await session.itineraryProvider.itineraries(origin: origin, destination: destination)
vps.itinerary = itineraries.first
note

Since iOS 18, ARSession may be stopped automatically when an ARView is hidden/dismissed. If you use ARView, see the workaround in the sample application.

Examples​

For sample implementations, see the official sample-apps repository.