reearth.sketch
The Re:Earth Visualizer includes a powerful sketch feature that enables users to dynamically draw custom markers, polylines, polygons, and more directly on the map. This functionality is accessible through the plugin API via reearth.sketch
.
Properties
tool
Get current sketch tool.
Syntax
Return Value
Type SketchType = | "marker" | "polyline" | "circle" | "rectangle" | "polygon" | "extrudedCircle" | "extrudedRectangle" | "extrudedPolygon"
options
Get current sketch options.
Syntax
Return Value
Type
- color: Specifies the primary color for the sketch geometry.
- appearance: Defines the styles applied to the sketch geometry once the drawing is completed.
- dataOnly: When set to true, the sketch will not append a new layer to the map after drawing. Default:
false
(Note: this option will be set totrue
in Re:Earth Visualizer Editor). - disableShadow: Determines whether shadows are displayed for the drawn geometry. Default:
false
. - rightClickToAbort: Enables the ability to abort the current drawing by right-clicking the mouse. Default:
true
. (Note: this option will be set tofalse
in Re:Earth Visualizer Editor). - autoResetInteractionMode: Automatically resets the viewer’s interaction mode to the default after completing a drawing. Default:
true
.
Methods
setTool
Configure the sketch tool to a specific type, or set it to undefined to exit sketch mode.
Syntax
Parameters
type
Type SketchType | undefined
Return Value
None (void)
. The method performs its operation without returning a value.
overrideOptions
This method is used to override the current sketch options.
Syntax
Parameters
options
Type SketchOptions
Return Value
None (void)
. The method performs its operation without returning a value.
Events
create
This event is triggered when a sketch drawing is successfully completed.
Syntax
Parameters
prop
Type
- layerId: The ID of the sketch layer. This property will not be available if the
dataOnly
option is enabled. - featureId: The ID of the sketch feature. This property will also be unavailable if the
dataOnly
option is enabled. - feature: A
GeoJSON
object, withid
type
positions
extrudedHeight
inproperties
.
Example
toolChange
This event will be triggered when sketch tool changes.
Syntax
Parameters
type
Type SketchType | undefined