Skip to main content

alphaThis is a new frontend component. Help us improve it and give your feedback on Slack.

Context

Context object providing access to configuration, state, and services. This object is passed to various callbacks and components throughout the application.

Properties


appConfig

Type: Object

Application configuration passed to the InteractiveMap constructor.


appState

Type: Object

Current application state, including:

{
breakpoint: 'mobile' | 'tablet' | 'desktop',
interfaceType: 'mouse' | 'touch' | 'keyboard',
// ... other app state
}

iconRegistry

Type: Object

Registry of icons available for use in buttons and controls.


mapProvider

Type: MapProvider

The map provider instance. Provides methods to interact with the underlying map engine.

// Example usage
const center = context.mapProvider.getCenter()
context.mapProvider.setView({ zoom: 10 })

mapState

Type: Object

Current map state, including:

{
zoom: 8,
center: [-1.5, 52.5],
bounds: [...],
// ... other map state
}

services

Type: Object

Core services for interacting with the application.

announce

Updates the map's aria-live region with a screen reader announcement. Use this to communicate important state changes to assistive technology users.

[!NOTE] This will override any pending core messages, so be sure to include necessary context. This function is experimental and subject to change.

context.services.announce('3 results found')

reverseGeocode

Returns a location description for the given coordinates. Uses the reverseGeocodeProvider if configured in options.

const description = await context.services.reverseGeocode(zoom, center)
// e.g. "Manchester, Greater Manchester"

[!NOTE] Further work is planned to provide richer results with optional detail levels and zoom-dependent descriptions.

closeApp

Closes the map if in fullscreen mode and returns to the previous page. Use this when your interaction needs to exit the map entirely.

context.services.closeApp()

eventBus

Pub/sub event bus for communication within the application.

const { eventBus, events } = context.services
// Subscribe to an event
eventBus.on(events.APP_PANEL_OPENED, ({ panelId }) => {
console.log('Panel opened:', panelId)
})
// Unsubscribe from an event
eventBus.off(events.APP_PANEL_OPENED, handler)
// Emit an event
eventBus.emit(events.MY_CUSTOM_EVENT, { data: 'value' })

events

Event name constants for use with eventBus. See Events for available events.