Class: CadControl

CadControl(optionsopt)

Control with snapping functionality for geometry alignment.

Constructor

new CadControl(optionsopt)

Parameters:
Name Type Attributes Description
options Object <optional>
Tool options.
Properties
Name Type Attributes Description
drawCustomSnapLines function <optional>
Allow to draw more snapping lines using selected corrdinaites.
filter function <optional>
Returns an array containing the features to include for CAD (takes the source as a single argument).
nbClosestFeatures Number <optional>
Number of features to use for snapping (closest first). Default is 5.
snapTolerance Number <optional>
Snap tolerance in pixel for snap lines. Default is 10.
showSnapLines Boolean <optional>
Whether to show snap lines (default is true).
showSnapPoints Boolean <optional>
Whether to show snap points around the closest feature.
showOrthoLines Boolean <optional>
Whether to show snap lines that arae perpendicular to segment (default is true).
showSegmentLines Boolean <optional>
Whether to show snap lines that extends a segment (default is true).
snapLinesOrder Boolean <optional>
Define order of display of snap lines, must be an array containing the following values 'ortho', 'segment', 'vh'. Default is ['ortho', 'segment', 'vh', 'custom'].
snapPointDist Number <optional>
Distance of the snap points (default is 30).
useMapUnits Boolean <optional>
Whether to use map units as measurement for point snapping. Default is false (pixel are used).
snapStyle ol.style.Style.StyleLike <optional>
Style used for the snap layer.
linesStyle ol.style.Style.StyleLike <optional>
Style used for the lines layer.
orthoLinesStyle ol.style.Style.StyleLike <optional>
Style used for the lines layer.
segmentLinesStyle ol.style.Style.StyleLike <optional>
Style used for the lines layer.
Style ol.style.Style.StyleLike <optional>
Style used for the lines layer.
Source:

Extends

Members

(private) className :string

Html class name of the control button.
Type:
  • string
Overrides:
Source:

(private) dialogTarget :HTMLElement

Specify a target if you want the dialog div used by the control to be rendered outside of the map's viewport.
Type:
  • HTMLElement
Overrides:
Source:

(private) drawCustomSnapLines :function

Function to draw more snapping lines.
Type:
  • function
Source:

(private) editor :ole.Editor

ole.Editor instance.
Type:
  • ole.Editor
Overrides:
Source:

(private) filter :function

Filter the features to snap with.
Type:
  • function
Source:

(private) layerFilter :function

Filter editable layer. Used by select interactions instead of the old source property.
Type:
  • function
Overrides:
Source:

(private) linesLayer :ol.layer.Vector

Layer for colored lines indicating intersection point between snapping lines.
Type:
  • ol.layer.Vector
Source:

(private) nbClosestFeatures :Number

Number of features to use for snapping (closest first). Default is 5.
Type:
  • Number
Source:

(private) pointerInteraction :ol.interaction.Pointer

Interaction for handling move events.
Type:
  • ol.interaction.Pointer
Source:

(private) properties :object

Control properties.
Type:
  • object
Overrides:
Source:

(private) snapInteraction :ol.interaction.Snap

Interaction for snapping
Type:
  • ol.interaction.Snap
Source:

(private) snapLayer :ol.layer.Vector

Layer for drawing snapping geometries.
Type:
  • ol.layer.Vector
Source:

(private) snapTolerance :Number

Snap tolerance in pixel.
Type:
  • Number
Source:

(private) source :ol.source.Vector

Source with edit features.
Type:
  • ol.source.Vector
Overrides:
Source:

(private) standalone :Boolean

Type:
  • Boolean
Overrides:
Source:

(private) title :string

Control title.
Type:
  • string
Overrides:
Source:

Methods

activate()

Activate the control
Overrides:
Source:

(private) closeDialog()

Closes the control dialog.
Overrides:
Source:

deactivate(silentopt)

Dectivate the control
Parameters:
Name Type Attributes Description
silent boolean <optional>
Do not trigger an event.
Overrides:
Source:

(private) drawSnapLines(coordinate, features)

Draws snap lines by building the extent for a pair of features.
Parameters:
Name Type Description
coordinate ol.Coordinate Mouse pointer coordinate.
features Array.<ol.Feature> List of features.
Source:

(private) drawSnapPoints(coordinate, feature)

Adds snap points to the snapping layer.
Parameters:
Name Type Description
coordinate ol.Coordinate cursor coordinate.
feature ol.eaturee Feature to draw the snap points for.
Source:

getActive() → {Boolean}

Returns the active state of the control.
Overrides:
Source:
Returns:
Active state.
Type
Boolean

(private) getClosestFeatures(coordinate, numFeatures) → {Array.<ol.Feature>}

Returns a list of the {num} closest features to a given coordinate.
Parameters:
Name Type Description
coordinate ol.Coordinate Coordinate.
numFeatures Number Number of features to search.
Source:
Returns:
List of closest features.
Type
Array.<ol.Feature>

getDialogTemplate()

Source:

getElement() → {Element}

Returns the control's element.
Overrides:
Source:
Returns:
the control element.
Type
Element

getOrthoLines()

For each segment, we calculate lines that are perpendicular.
Source:

getProperties() → {object}

Return properties.
Overrides:
Source:
Returns:
Copy of control properties.
Type
object

(private) getRotatedExtent(geometry) → {Array.<number>}

Returns an extent array, considers the map rotation.
Parameters:
Name Type Description
geometry ol.Geometry An OL geometry.
Source:
Returns:
extent array.
Type
Array.<number>

getSegmentLines()

For each segment, we calculate lines that extends it.
Source:

(private) onClick()

Click handler for the control element.
Overrides:
Source:

(private) onMove(evt)

Handle move event.
Parameters:
Name Type Description
evt ol.MapBrowserEvent Move event.
Source:

openDialog()

Open the control's dialog (if defined).
Overrides:
Source:

(protected) setEditor(editor)

Introduce the control to it's editor.
Parameters:
Name Type Description
editor ole.Editor OLE Editor.
Overrides:
Source:

(protected) setMap(map)

Sets the map of the control.
Parameters:
Name Type Description
map ol.Map The map object.
Overrides:
Source:

setProperties(properties, silentopt)

Set properties.
Parameters:
Name Type Attributes Description
properties object New control properties.
silent boolean <optional>
If true, no propertychange event is triggered.
Overrides:
Source: