The Tools controller allows you to let users draw elements on the map.
setTool (tool: null | ToolType ): void
Sets the tool to use for drawing elements on the map.
Use this method to programmatically activate drawing tools for users. When a tool is set, users can draw elements on the map using that tool. Set to null to deactivate all drawing tools.
The tool to set, or null to deactivate all tools.
void
getTool (): Promise<null | ToolType >
Gets the current tool, if any is in use.
Use this method to check which drawing tool is currently active, if any.
Promise<null | ToolType >
A promise that resolves to the current tool, or null if no tool is in use.
onToolChange (args: { handler: (tool: null | ToolType ) => void; }): VoidFunction
Listens for changes to the current tool.
Use this to react to tool changes, such as updating your UI to reflect the currently active drawing tool.
{ handler: (tool: null | ToolType ) => void; }
This callback is called with the current tool whenever the tool changes.
VoidFunction
setToolSettings (settings: InputToolSettings ): void
Sets the settings for the current tool.
Use this method to configure how drawing tools behave, such as setting colors, stroke widths, or other tool-specific properties.
The settings to set for the specified tool.
void
getToolSettings <T>(tool: T): Promise<ToolSettingsMap [T]>
Gets the settings for the chosen tool.
Use this method to retrieve the current configuration of a drawing tool.
Type Parameters
The tool to get settings for.
Promise<ToolSettingsMap [T]>
A promise that resolves to the settings for the chosen tool.
onToolSettingsChange (args: { handler: (settings: ToolSettingsChangeEvent ) => void; }): VoidFunction
Listens for changes to the settings on all tools.
Use this to react to tool setting changes, such as updating your UI to reflect the current tool configuration.
VoidFunction
A function to unsubscribe from the listener.
Last updated 5 months ago