Skip to main content

VPSLocationSource

wemap-sdk-js


Class: VPSLocationSource

LocationSource that combines VPS positioning with PDR and attitude tracking

This source provides:

  • VPS: Visual positioning using camera (provides position and attitude)
  • PDR: Pedestrian Dead Reckoning via AbsolutePositionProvider (provides continuous position updates)
  • AbsoluteAttitude: Device orientation tracking

VPS (Visual Positioning System) uses the device camera to identify the user's location by matching visual features. After an initial VPS scan, PDR provides continuous position updates as the user moves.

Example

import { VPSLocationSource } from '@wemap/positioning';

const vpsSource = new VPSLocationSource({
usePositionSmoother: true
});

vpsSource.onUpdate((pose) => {
console.log('Position:', pose.position);
console.log('Attitude:', pose.attitude);
});

await vpsSource.start();

// Start VPS scan (requires camera access)
const scanSuccess = await vpsSource.startScan();
if (scanSuccess) {
console.log('VPS scan successful!');
}

Extends

Constructors

Constructor

new VPSLocationSource(config): VPSLocationSource

Parameters

config

VPSLocationSourceConfig = {}

Returns

VPSLocationSource

Overrides

LocationSource.constructor

Properties

isStarted

isStarted: boolean = false

Inherited from

LocationSource.isStarted


scanStatus

scanStatus: "scanning" | "stopped" = 'stopped'

Methods

offError()

offError(callback): void

Remove the error callback

Parameters

callback

(error) => void

The callback function to remove

Returns

void

Inherited from

LocationSource.offError


offUpdate()

offUpdate(callback): void

Remove the update callback

Parameters

callback

(data) => void

The callback function to remove

Returns

void

Inherited from

LocationSource.offUpdate


onError()

onError(callback): void

Register a callback to receive error events

Parameters

callback

(error) => void

Function to call when an error occurs

Returns

void

Inherited from

LocationSource.onError


onUpdate()

onUpdate(callback): void

Register a callback to receive pose updates

The callback receives complete pose data. If there's already a current pose available, the callback will be called immediately with that data.

Parameters

callback

(data) => void

Function to call when pose data is updated

Returns

void

Example

locationSource.onUpdate((pose) => {
console.log('Current pose:', pose);
});

Inherited from

LocationSource.onUpdate


start()

start(): Promise\<void>

Start the location source and begin emitting updates

Returns

Promise\<void>

Overrides

LocationSource.start


startScan()

startScan(): Promise\<boolean>

Start the VPS scan

Initiates a visual positioning scan using the device camera. This should be called when the user wants to determine their initial position. The scan will continue until a successful match is found or an error occurs.

Note: This requires camera permissions and the user should point the camera at recognizable visual features in the environment.

Returns

Promise\<boolean>

Promise that resolves to true if the scan was successful, false otherwise

Throws

If VPS is not available or endpoint is not configured

Example

await vpsSource.start();
const success = await vpsSource.startScan();
if (success) {
console.log('Position found via VPS!');
} else {
console.log('VPS scan failed');
}

stop()

stop(): Promise\<void>

Stop the location source and stop emitting updates

Returns

Promise\<void>

Overrides

LocationSource.stop


stopScan()

stopScan(): Promise\<void>

Stop the VPS scan

Stops an active VPS scan and releases camera resources.

Returns

Promise\<void>

Example

await vpsSource.stopScan();