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


init()

init(initOptions): Promise<void>

Initialize the core SDK

Fetches livemap data from the API using the provided emmid and token. This must be called before using other SDK features that depend on configuration.

Parameters

initOptions

InitOptions

Initialization options

Returns

Promise<void>

Throws

If emmid or token are missing

Example

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

getIndoorOptions()

static getIndoorOptions(): IndoorOptions

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:

  • tilesStylestyle
  • initialBoundsbounds (initial view; takes precedence over center/zoom)
  • maxBounds, minZoom, maxZoom → same
  • initialBearingbearing, pitchStartpitch
  • draggingdragPan, pitchEnableddragRotate / pitchWithRotate
  • scrollWheelZoomscrollZoom, lockedinteractive (negated)

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

Returns

IndoorOptions

The map parameters from the parsed snippet.


getMapOptions()

static getMapOptions(): object

Returns

object

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>