API

The runtime API of the plugin is exposed through the InteractiveMapApi interface. An instance is passed to custom code (e.g. Custom JS, Action Run Script) and gives you full programmatic control over the map: scenes, viewport, audio, styles, UI widgets and events.

MapApi

The root facade for a single player instance.

MethodDescription
on(event, handler)Subscribes to a map event (see Events). Returns an unsubscribe function — call it to remove the listener.
getResourceUrl(type)Returns the base URL for plugin resources. type: "assets" | "icons".
getId()Returns the ID of the current interactive map.
generateId()Generates a new unique ID (same format used internally for scenes, layers and controls).
getContainer()Returns the host HTMLDivElement the map is mounted into.
getShadowRoot()Returns the ShadowRoot of the map element. Use it to query internal DOM when needed.
start()Starts the map (initialization, initial scene, auto-load, etc.).
destroy()Fully destroys the map instance and releases resources.
styleApiRead-only property. Returns the StyleApi instance.
audioApiRead-only property. Returns the AudioApi instance.
viewportApiRead-only property. Returns the ViewportApi instance.
sceneApiRead-only property. Returns the SceneApi instance.
uiApiRead-only property. Returns the UIApi instance.

Sub APIs

Sub-APIs are exposed directly as getters. You can always access them as core properties on the root instance:

StyleApi – map.styleApi

Applies/removes emotion styles (CSS classes) on the map.

MethodDescription
applyStyle(style: EmotionStyle): stringApplies a style and returns the generated class name.
removeStyle(className: string): voidRemoves a previously applied style by its class name.

AudioApi – map.audioApi

Sound playback control.

MethodDescription
playFromAction(action, context?)Plays a sound defined by a PlaySoundAction. Optional context: { sceneId?, layerId? } identifies the origin of the sound.
stop(channel?)Stops a specific sound/channel; omit the argument to stop everything.
setMuted(muted: boolean)Mutes/unmutes audio.
setMasterVolume(volume: number)Sets the master volume.
dispose()Releases all audio resources.

ViewportApi – map.viewportApi

Camera control: pan, zoom, fullscreen.

MethodDescription
setOptions(options: Partial<ViewportOptions>)Merges new viewport options (background, pan, zoom, constraints — see ViewportOptions in map.ts).
getOptions(): Readonly<ResolvedViewportOptions>Returns the fully resolved (with defaults applied) viewport options.
lookAt(params: LookAtParams): Promise<ViewportApi>Animates the camera to the given target. Resolves when the animation finishes.
lookAtLayer(params: LookAtLayerParams): Promise<ViewportApi>Animates the camera to focus a specific layer.
zoom(params: ZoomParams): Promise<ViewportApi>Animates to an absolute zoom level.
zoomBy(params: ZoomByParams): Promise<ViewportApi>Animates zoom by a relative delta.
zoomAndCenter(params: ZoomParams): Promise<ViewportApi>Sets the zoom level and centers the canvas.
toggleFullscreen()Toggles fullscreen mode.
isFullscreen(): booleanReturns whether fullscreen is currently active.

All animated methods are chainable: await map.viewportApi.zoom({...}).then(api => api.lookAt({...})).

SceneApi – map.sceneApi

Scene and layer management.

MethodDescription
size(): numberNumber of scenes.
has(sceneId): booleanWhether a scene exists.
get(sceneId): Scene | nullReturns a scene by ID.
getIndex(sceneId): number | nullReturns the scene position in the list.
getLayer(sceneId, layerId): Layer | nullReturns a layer within a scene.
getActive(): Scene | nullReturns the currently visible scene.
getList(): Scene[]Returns all scenes.
getNext(loop?): Scene | nullNext scene; loop: true wraps around.
getPrev(loop?): Scene | nullPrevious scene; loop: true wraps around.
setDefault(sceneId | null): voidSets/clears the default (initial) scene.
getDefault(): string | nullReturns the default scene ID.
add(scene): booleanAdds a scene; returns true on success.
remove(sceneId): booleanRemoves a scene; returns true on success.
move(sceneIds, pos): booleanMoves the given scenes to position pos.
show(sceneId): booleanShows a scene (fires scene:show).
hide(): booleanHides the current scene (fires scene:hide).

UIApi – map.uiApi

Control widget management.

MethodDescription
size(): numberNumber of registered widgets.
has(controlId): booleanWhether a widget exists.
get(controlId): ControlWidget | nullReturns a widget by ID.
add(widget: ControlWidget): booleanRegisters a widget; returns true on success (fires widget:add).
remove(controlId): booleanRemoves a widget (fires widget:remove).