Hierarchy (View Summary)

Constructors

  • Constructor: OpenLayers.Control.Snapping Creates a new snapping control. A control is constructed with an editable layer and a set of configuration objects for target layers. While the control is active, dragging vertices while drawing new features or modifying existing features on the editable layer will engage snapping to features on the target layers. Whether a vertex snaps to a feature on a target layer depends on the target layer configuration.

    Parameters: options - {Object} An object containing all configuration properties for the control.

    Valid options: layer - {<OpenLayers.Layer.Vector>} The editable layer. Features from this layer that are digitized or modified may have vertices snapped to features from any of the target layers. targets - {Array(Object | OpenLayers.Layer.Vector)} A list of objects for configuring target layers. See valid properties of the target objects below. If the items in the targets list are vector layers (instead of configuration objects), the defaults from the property will apply. The editable layer itself may be a target layer, allowing newly created or edited features to be snapped to existing features from the same layer. If no targets are provided the layer given in the constructor (as ) will become the initial target. defaults - {Object} An object with default properties to be applied to all target objects. greedy - {Boolean} Snap to closest feature in first target layer that applies. Default is true. If false, all features in all target layers will be checked and the closest feature in all target layers will be chosen. The greedy property determines if the order of the target layers is significant. By default, the order of the target layers is significant where layers earlier in the target layer list have precedence over layers later in the list. Within a single layer, the closest feature is always chosen for snapping. This property only determines whether the search for a closer feature continues after an eligible feature is found in a target layer.

    Valid target properties: layer - {<OpenLayers.Layer.Vector>} A target layer. Features from this layer will be eligible to act as snapping target for the editable layer. tolerance - {Float} The distance (in pixels) at which snapping may occur. Default is 10. node - {Boolean} Snap to nodes (first or last point in a geometry) in target layer. Default is true. nodeTolerance - {Float} Optional distance at which snapping may occur for nodes specifically. If none is provided, will be used. vertex - {Boolean} Snap to vertices in target layer. Default is true. vertexTolerance - {Float} Optional distance at which snapping may occur for vertices specifically. If none is provided, will be used. edge - {Boolean} Snap to edges in target layer. Default is true. edgeTolerance - {Float} Optional distance at which snapping may occur for edges specifically. If none is provided, will be used. filter - {<OpenLayers.Filter>} Optional filter to evaluate to determine if feature is eligible for snapping. If filter evaluates to true for a target feature a vertex may be snapped to the feature. minResolution - {Number} If a minResolution is provided, snapping to this target will only be considered if the map resolution is greater than or equal to this value (the minResolution is inclusive). Default is no minimum resolution limit. maxResolution - {Number} If a maxResolution is provided, snapping to this target will only be considered if the map resolution is strictly less than this value (the maxResolution is exclusive). Default is no maximum resolution limit.

    Parameters

    • options: {}

    Returns Snapping

Properties

active: boolean
autoActivate: boolean
displayClass: string
div: HTMLElement
events: Events
feature: null | Vector<Geometry>

Property: feature {<OpenLayers.Feature.Vector>} The current editable feature.

handler: null | Handler
map: null | Map

Property: map {<OpenLayers.Map>} this gets set in the addControl() function in OpenLayers.Map

precedence: string[]

Property: precedence {Array} List representing precedence of different snapping types. Default is "node", "vertex", "edge".

TYPE_BUTTON: 1

Constant: OpenLayers.Control.TYPE_BUTTON

TYPE_TOGGLE: 2

Constant: OpenLayers.Control.TYPE_TOGGLE

TYPE_TOOL: 3

Constant: OpenLayers.Control.TYPE_TOOL

Methods

  • APIMethod: activate Explicitly activates a control and it's associated handler if one has been set. Controls can be deactivated by calling the deactivate() method.

    Returns: {Boolean} True if the control was successfully activated or false if the control was already active.

    Returns boolean

  • APIMethod: deactivate Deactivates a control and it's associated handler if any. The exact effect of this depends on the control itself.

    Returns: {Boolean} True if the control was effectively deactivated or false if the control was already inactive.

    Returns boolean

  • Method: destroy The destroy method is used to perform any clean up before the control is dereferenced. Typically this is where event listeners are removed to prevent memory leaks.

    Returns void

  • Method: draw The draw method is called when the control is ready to be displayed on the page. If a div has not been created one is created. Controls with a visual component will almost always want to override this method to customize the look of control.

    Parameters: px - {<OpenLayers.Pixel>} The top-left pixel position of the control or null.

    Returns: {DOMElement} A reference to the DIV DOMElement containing the control

    Parameters

    Returns HTMLElement

  • Method: setMap Set the map property for the control. This is done through an accessor so that subclasses can override this and take special action once they have their map variable set.

    Parameters: map - {<OpenLayers.Map>}

    Parameters

    Returns void