Geoportal Extension for OpenLayers
API Reference

Class: DrawingActionByDefaut

DrawingActionByDefaut

Drawing action for the Reporting control.
This class handles drawing actions on the map, allowing users to create and manage drawings.

new DrawingActionByDefaut(map)

Controls/Reporting/Reporting.js, line 382

The constructor initializes the action with an optional map instance.
If no map is provided, it defaults to null.
It also initializes properties for data, map, DOM elements, and the Drawing instance.
The Drawing instance is used to manage the drawing functionality on the map.
The DOM elements for the drawing button and panel will be set by the IoC (Inversion of Control) container.

Name Type Description
map ol.Map optional

Optional OpenLayers map instance.

Methods

active()

Controls/Reporting/Reporting.js, line 404

This method initializes the Drawing instance if it is not already created.
It sets the Drawing instance to be active and configures its panel.
The Drawing instance allows users to create and manage drawings on the map.
It also sets the position of the Drawing panel to be relative, allowing it to be positioned within its parent container.
If the Drawing instance is already initialized, it simply makes the Drawing panel visible.
This method is typically called when the user wants to start drawing on the map.

clear()

Controls/Reporting/Reporting.js, line 447

This method resets the data property to null,
effectively clearing any previously captured drawing data.
It is intended to be called when the drawing needs to be reset or cleared.
It does not perform any action on the Drawing instance itself.
This method is useful when the user wants to start a new drawing or discard the current drawing.
It ensures that the data property is cleared, allowing for a fresh start on the next drawing action.
It does not remove the Drawing instance or its event listeners, allowing the user to continue drawing if desired.

disable()

Controls/Reporting/Reporting.js, line 427

This method collapses the Drawing instance, effectively hiding the drawing panel.
It is typically called when the user wants to stop drawing or hide the drawing panel.
If the Drawing instance is not initialized, it simply returns without performing any action.
This method is intended to be called when the drawing functionality is no longer needed.
It ensures that the Drawing panel is hidden and the Drawing instance is not active.

getData(){Object}

Controls/Reporting/Reporting.js, line 471

This method retrieves the data captured from the drawing.
It exports the features from the Drawing instance
and returns them as an object.
If no drawing data is available, it returns an empty object.

Returns:
- Data for this action.
Example
var data = drawingAction.getData();
console.log(data);
// Output:
// {
//   drawing: {
//     type: "FeatureCollection",
//     features: [...]
//   }
// }

setFormat(format)

Controls/Reporting/Reporting.js, line 514

Set the format for exporting drawings

Name Type Description
format String

The format to set for exporting drawings.

setMap(map)

Controls/Reporting/Reporting.js, line 492

This method sets the map instance for the Drawing action.
It initializes the Drawing instance if it is not already created.
If the Drawing instance is already initialized, it simply updates the map property.
This method is typically called when the map is ready or when the Drawing action needs to be associated with a specific map instance.

Name Type Description
map ol.Map

Map.

setTarget(dom)

Controls/Reporting/Reporting.js, line 501

Set the target DOM element for the Drawing action

Name Type Description
dom DOMElement

The DOM element to set as the target for the Drawing action.