DrawingManager / DrawingManagerF
TheDrawingManager component provides a graphical interface for users to draw shapes on the map. Both DrawingManager and DrawingManagerF are available - they are functionally identical.
Props
DrawingManager options object. Can include options for each drawing mode (markerOptions, polylineOptions, etc.).
Changes the DrawingManager’s drawing mode, which defines the type of overlay to be added on the map.
Accepted values are
'marker', 'polygon', 'polyline', 'rectangle', 'circle', or null.
A drawing mode of null means that the user can interact with the map as normal, and clicks do not draw anything.Event Handlers
Fired when the user has finished drawing a circle.
Fired when the user has finished drawing a marker.
Fired when the user has finished drawing an overlay of any type. The event contains the overlay instance and type.
Fired when the user has finished drawing a polygon.
Fired when the user has finished drawing a polyline.
Fired when the user has finished drawing a rectangle.
Lifecycle Callbacks
Called when the DrawingManager instance has loaded.
Called when the component unmounts.
Example
Usage Notes
- The DrawingManager requires the drawing library to be loaded. Make sure to include it in your
useJsApiLoaderorLoadScriptcomponent: - When a shape is completed, you typically want to set
drawingModetonullto prevent continuous drawing. - The completed shapes remain on the map. You can store references to them via the completion handlers and remove them later if needed.