Skip to main content

CoreConfig

wemap-sdk-js


Class: CoreConfig

Core configuration class for initializing the Wemap SDK

This class handles SDK initialization, fetches livemap data from the API, and provides access to the global configuration.

Example​

import { core } from '@wemap/core';

// Initialize the SDK
await core.init({
emmid: 'your-emmid',
token: 'your-token',
env: 'production'
});

// Access configuration
const config = CoreConfig.getConfig();

Methods​

createBuildingProvider()​

createBuildingProvider(): (bbox) => Promise<Building[]>

Build a building provider for the initialized livemap: a function that returns the buildings whose bbox intersects a given viewport.

This is the concrete data source @wemap/map uses for building selection when indoor.enable is set in the livemap snippet. Integrators normally don't call it directly.

await core.init({ emmid, token });
const provider = core.createBuildingProvider();
const buildings = await provider(map.getBounds());

Returns​

A (bbox) => Promise<Building[]> bound to this livemap.

(bbox) => Promise<Building[]>


createBuildingService()​

createBuildingService(): BuildingService

Build a building service for the initialized livemap.

await core.init({ emmid, token });
const service = core.createBuildingService();
const buildings = await service.getBuildingsFromBbox(map.getBounds());

Returns​

BuildingService

A BuildingService bound to this livemap.


createGeocodingService()​

createGeocodingService(options?): GeocodingService

Build a geocoding client (forward + reverse) against the Wemap geocoding API.

Does not require core.init() — pass language / region / bbox defaults via options when needed.

const geocoding = core.createGeocodingService({ language: 'fr', region: 'fr' });
const place = await geocoding.search('Paris');
const address = await geocoding.reverseGeocode(48.85, 2.35);

Parameters​

options?​

GeocodingServiceOptions

Returns​

GeocodingService


createPinpointManager()​

createPinpointManager(): PinpointManager

Build a pinpoint manager bound to the initialized livemap.

await core.init({ emmid, token });
const pinpoints = core.createPinpointManager();
const { items } = await pinpoints.search({
query: 'café',
...boundsToDelta(map.getBounds()),
level: map.getLevel() ?? undefined,
});

Returns​

PinpointManager


createWallService()​

createWallService(): WallService

Build a wall service for the initialized livemap.

await core.init({ emmid, token });
const service = core.createWallService();
const walls = await service.searchWalls(venueId);

Returns​

WallService

A WallService bound to this livemap.


init()​

init(initOptions): Promise<void>

Initialize the core SDK

Fetches livemap data from the API using the provided emmid and token, or parses an already-fetched livemap without any request. This must be called before using other SDK features that depend on configuration.

Parameters​

initOptions​

InitOptions

Initialization options

Returns​

Promise<void>

Throws​

If neither livemap nor both emmid and token are given

Example​

await core.init({
emmid: 'abc123',
token: 'xyz789',
env: 'production'
});

// Livemap already fetched by the host app:
await core.init({ livemap, env: 'development' });

getClientInfo()​

static getClientInfo(): ClientInfo

The application identity passed to core.init (empty when none was given). SDK packages merge it over their own defaults when calling backends.

Returns​

ClientInfo


getIndoorOptions()​

static getIndoorOptions(): IndoorOptions

Indoor settings from the livemap snippet (indoor.enable, indoor.minZoom).

Returns​

IndoorOptions


getMapOptions()​

static getMapOptions(): object

Map-related parameters derived from the livemap snippet, shaped for direct use when creating a map (e.g. @wemap/map's WemapMap).

Translates livemap semantics into renderer options:

  • tilesStyle → style
  • initialBounds → bounds (initial view; takes precedence over center/zoom)
  • maxBounds, minZoom, maxZoom → same (snippet zooms are maplibre zooms)
  • initialBearing → bearing, pitchStart → pitch
  • dragging → dragPan, pitchEnabled → dragRotate / pitchWithRotate
  • scrollWheelZoom → scrollZoom, locked → interactive (negated)

Applied automatically by @wemap/map's WemapMap after core.init(); constructor options override these defaults.

Returns​

object

The map parameters from the parsed snippet.

bearing​

bearing: any = config.initialBearing

bounds​

bounds: BoundingBox = config.initialBounds

dragPan​

dragPan: any = config.dragging

dragRotate​

dragRotate: any = config.pitchEnabled

interactive​

interactive: boolean = !config.locked

maxBounds​

maxBounds: BoundingBox = config.maxBounds

maxZoom​

maxZoom: any = config.maxZoom

minZoom​

minZoom: any = config.minZoom

pitch​

pitch: any = config.pitchStart

pitchWithRotate​

pitchWithRotate: any = config.pitchEnabled

scrollZoom​

scrollZoom: any = config.scrollWheelZoom

style​

style: any = config.tilesStyle


getTagsConfig()​

static getTagsConfig(): LivemapTagsConfig

The livemap's tag configuration — the tags authored on the map and the categories they can be grouped by (from the snippet's usetags). Use it to build tag filters, legends or category menus.

Returns empty tags / categories arrays when the livemap has no tags or the SDK has not been initialized.

await core.init({ emmid, token });
const { tags, categories } = CoreConfig.getTagsConfig();
const transportTags = tags.filter((t) => t.category === 'transport');

Returns​

LivemapTagsConfig


getTheme()​

static getTheme(): WemapTheme

The resolved SDK theme (built-in defaults merged with any core.init override). Returns the defaults when the SDK has not been initialized.

Returns​

WemapTheme


getThemeCssVariables()​

static getThemeCssVariables(): Record<string, string>

The resolved theme as CSS custom properties ({ '--wemap-color-primary': '#…', … }). UI packages apply these to their root element; their stylesheets reference the variables.

Returns​

Record<string, string>


getViewerOptions()​

static getViewerOptions(): object

360° viewer settings derived from the livemap snippet's arNavigationData. The VPS endpoint is the base URL the @wemap/viewer package fetches the image graph and panorama images from.

Returns { vpsEndpoint: null } when the livemap has no AR/VPS provider configured or the SDK has not been initialized.

Returns​

object

vpsEndpoint​

vpsEndpoint: string | null