Enables the user to draw on the map.

// example of Giro3D instantiation
const instance = new Instance(viewerDiv, options)
const map = new Map('myMap', { extent });
instance.add(map);

// Add our tool
const drawTool = new DrawTool(instance);

// Start and wait for result
drawTool.startAsAPromise()
.then((polygon) => {
// Use generated polygon as GeoJSON
})
// Or use events
drawTool.addEventListener('end', (polygon) => {
// Use generated polygon as GeoJSON
})
drawTool.start();

Hierarchy

Constructors

Accessors

Methods

  • Edits a GeoJSON geometry and returns a promise.

    Fires DrawToolEventMap.start event at start.

    Parameters

    • geometry: Geometry | Drawing

      GeoJSON geometry or Drawing instance to edit. If passing a Drawing, this tool takes full ownership over it, and will destroy it when done.

    Returns Promise<Geometry>

    Promise resolving to the GeoJSON geometry drawn

  • Pauses current drawing so click events are not captured. This is useful when the user is currently interacting with the camera.

    Returns void

  • Gets the current coordinates of the shape being drawn. In case of polygons, ensures the shape is closed.

    Returns null if the state is DrawToolState.READY or if the shape is empty.

    Returns [number, number, number][]

    Array of 3D coordinates

  • Gets the current GeoJSON geometry corresponding to the shape being drawn. In case of polygons, ensures the shape is closed.

    Returns null if the state is DrawToolState.READY or if the shape is empty.

    Returns Geometry

    GeoJSON geometry object