Skip to main content

LocationSource

wemap-sdk-js


Abstract Class: LocationSource

Base class for all location sources

Provides common functionality like callback management, pose merging, and map matching configuration that can be shared across different location source implementations.

Subclasses should implement the start() and stop() methods and call mergeAndEmitUpdate() when they receive pose updates from their underlying providers.

Example

class CustomLocationSource extends LocationSource {
async start() {
// Start your provider
provider.onUpdate((data) => {
this.mergeAndEmitUpdate(data);
});
}

async stop() {
// Stop your provider
}
}

Extended by

Implements

Constructors

Constructor

new LocationSource(): LocationSource

Returns

LocationSource

Properties

isStarted

isStarted: boolean = false

Methods

offError()

offError(callback): void

Remove the error callback

Parameters

callback

(error) => void

The callback function to remove

Returns

void

Implementation of

ILocationSource.offError


offUpdate()

offUpdate(callback): void

Remove the update callback

Parameters

callback

(data) => void

The callback function to remove

Returns

void

Implementation of

ILocationSource.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

Implementation of

ILocationSource.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);
});

Implementation of

ILocationSource.onUpdate


start()

abstract start(): Promise\<void>

Start the location source and begin emitting updates

Returns

Promise\<void>

Implementation of

ILocationSource.start


stop()

abstract stop(): Promise\<void>

Stop the location source and stop emitting updates

Returns

Promise\<void>

Implementation of

ILocationSource.stop