Skip to main content

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

PluginContext

Plugin components and callbacks receive the base Context plus the plugin-specific properties documented below.

PluginContext is received by:

Base Context Properties

See Context for the following properties available to all contexts:

  • appConfig - Application configuration
  • appState - Current application state
  • iconRegistry - Icon registry
  • mapProvider - Map provider instance
  • mapState - Current map state
  • services - Core services

Plugin-Specific Properties


pluginConfig

Type: Object

Plugin-specific configuration. Contains all properties from the PluginDescriptor except id and load.

When using the factory function pattern, any options passed to the factory become available here:

// When registering:
createScaleBarPlugin({ units: 'imperial' })
// Within the plugin:
const { units } = context.pluginConfig

See Creating a Plugin Descriptor for the full pattern.


pluginState

Type: Object

Plugin-specific state managed by the plugin's reducer, plus utilities for updating state.

{
// State values from your reducer's initialState
isActive: false,
// Dispatch function for updating plugin state
dispatch: ({ type, payload }) => { /* ... */ }
}
// Access state
const { isActive } = context.pluginState
// Update state
context.pluginState.dispatch({ type: 'setActive', payload: true })