Module: ol/interaction/Snap

ol/interaction/Snap


Classes

Snap

Type Definitions

Options{Object}

Properties:
Name Type Description
features Collection<Feature> | undefined

Snap to these features. Either this option or source should be provided.

source VectorSource | undefined

Snap to features from this source. Either this option or features should be provided

edge boolean
(defaults to true)

Snap to edges.

vertex boolean
(defaults to true)

Snap to vertices.

intersection boolean
(defaults to false)

Snap to intersections between segments.

pixelTolerance number
(defaults to 10)

Pixel tolerance for considering the pointer close enough to a segment or vertex for snapping.

segmenters Segmenters | undefined

Custom segmenters by Type. By default, the following segmenters are used:

  • Point: A one-dimensional segment (e.g. [[10, 20]]) representing the point.
  • LineString: One two-dimensional segment (e.g. [[10, 20], [30, 40]]) for each segment of the linestring.
  • Polygon: One two-dimensional segment for each segment of the exterior ring and the interior rings.
  • Circle: One two-dimensional segment for each segment of a regular polygon with 32 points representing the circle circumference.
  • GeometryCollection: All segments of the contained geometries.
  • MultiPoint: One one-dimensional segment for each point.
  • MultiLineString: One two-dimensional segment for each segment of the linestrings.
  • MultiPolygon: One two-dimensional segment for each segment of the polygons.

Segment{Array<Coordinate>}

An array of two coordinates representing a line segment, or an array of one coordinate representing a point.

SegmentData{Object}

Properties:
Name Type Description
feature Feature

Feature.

segment Segment

Segment.

isIntersection boolean | undefined

Is intersection.

A function taking a Geometry as argument and returning an array of Segments.

Segmenters{Object}

Each segmenter specified here will override the default segmenter for the corresponding geometry type. To exclude all geometries of a specific geometry type from being snapped to, set the segmenter to null.

Properties:
Name Type Description
Point Segmenter<Point> | null | undefined

Point segmenter.

LineString Segmenter<LineString> | null | undefined

LineString segmenter.

Polygon Segmenter<Polygon> | null | undefined

Polygon segmenter.

Circle Segmenter<Circle> | null | undefined

Circle segmenter.

GeometryCollection Segmenter<GeometryCollection> | null | undefined

GeometryCollection segmenter.

MultiPoint Segmenter<MultiPoint> | null | undefined

MultiPoint segmenter.

MultiLineString Segmenter<MultiLineString> | null | undefined

MultiLineString segmenter.

MultiPolygon Segmenter<MultiPolygon> | null | undefined

MultiPolygon segmenter.

SnappedInfo{Object}

Information about the last snapped state.

Properties:
Name Type Description
vertex Coordinate | null

The snapped vertex.

vertexPixel Pixel | null

The pixel of the snapped vertex.

feature Feature | null

The feature being snapped.

segment Segment | null

Segment, or null if snapped to a vertex.