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.
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.
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.
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
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 7 months ago