Class: Transform

ol.interaction. Transform

Interaction rotate


new Transform(options)

Parameters:
Name Type Description
options any
Properties
Name Type Argument Default Description
filter function

A function that takes a Feature and a Layer and returns true if the feature may be transformed or false otherwise.

layers Array.<ol.Layer>

array of layers to transform,

features ol.Collection.<ol.Feature>

collection of feature to transform,

condition ol.EventsConditionType | undefined

A function that takes an ol.MapBrowserEvent and a feature collection and returns a boolean to indicate whether that event should be handled. default: ol.events.condition.always.

addCondition ol.EventsConditionType | undefined

A function that takes an ol.MapBrowserEvent and returns a boolean to indicate whether that event should be handled ie. the feature will be added to the transforms features. default: ol.events.condition.never.

hitTolerance number | undefined

Tolerance to select feature in pixel, default 0

translateFeature bool

Translate when click on feature

translate bool

Can translate the feature

translateBBox bool

Enable translate when the user drags inside the bounding box

stretch bool

can stretch the feature

scale bool

can scale the feature

rotate bool

can rotate the feature

noFlip bool

prevent the feature geometry to flip, default false

selection bool

the intraction handle selection/deselection, if not use the select prototype to add features to transform, default true

keepAspectRatio ol.events.ConditionType | undefined

A function that takes an ol.MapBrowserEvent and returns a boolean to keep aspect ratio, default ol.events.condition.shiftKeyOnly.

modifyCenter ol.events.ConditionType | undefined

A function that takes an ol.MapBrowserEvent and returns a boolean to apply scale & strech from the center, default ol.events.condition.metaKey or ol.events.condition.ctrlKey.

enableRotatedTransform boolean

Enable transform when map is rotated

keepRectangle boolean <optional>
false

keep rectangle when possible

buffer number <optional>

Increase the extent used as bounding box, default 0

style *

list of ol.style for handles

pointRadius number | Array.<number> | function <optional>
0

radius for points or a function that takes a feature and returns the radius (or [radiusX, radiusY]). If not null show handles to transform the points

Fires:
  • (event:select|rotatestart|rotating|rotateend|translatestart|translating|translateend|scalestart|scaling|scaleend)

Extends

  • ol.interaction.Pointer

Members


Cursors

Cursors for transform


style

Style for handles

Methods


drawSketch_(draw)

Draw transform sketch

Parameters:
Name Type Description
draw boolean

only the center


getCenter()

Get the rotation center

Returns:
Type
ol.coordinate | undefined

getFeatures()

Get the features that are selected for transform

Returns:

ol.Collection


getGeometryRotateToZero_(f, clone, rotated)

Rotate feature from map view rotation

Parameters:
Name Type Description
f ol.Feature

the feature

clone boolean

clone resulting geom

rotated ol.geom.Geometry

geometry


handleUpEvent_(evt)

Parameters:
Name Type Description
evt ol.MapBrowserEvent

Map browser event.

Returns:

false to stop the drag sequence.

Type
boolean

select(feature, add)

Select a feature to transform

Parameters:
Name Type Description
feature ol.Feature

the feature to transform

add boolean

true to add the feature to the selection, default false


setActive(b)

Activate/deactivate interaction

Parameters:
Name Type Description
b bool

setCenter(c)

Set the rotation center

Parameters:
Name Type Description
c ol.coordinate | undefined

the center point, default center on the objet


setDefaultStyle( [options] [, stroke] [, fill] [, pointStroke] [, pointFill])

Set default sketch style

Parameters:
Name Type Argument Description
options Object <optional>
stroke ol.style.Stroke <optional>

stroke style for selection rectangle, default red dash

fill ol.style.Fill <optional>

fill style for selection rectangle, default red

pointStroke ol.style.Stroke <optional>

stroke style for handles, default red

pointFill ol.style.Fill <optional>

fill style for handles, default white


setMap(map)

Remove the interaction from its current map, if any, and attach it to a new map, if any. Pass null to just remove the interaction from the current map.

Parameters:
Name Type Description
map ol.Map

Map.


setPointRadius( [pointRadius])

Set the point radius to calculate handles on points

Parameters:
Name Type Argument Default Description
pointRadius number | Array.<number> | function <optional>
0

radius for points or a function that takes a feature and returns the radius (or [radiusX, radiusY]). If not null show handles to transform the points


setSelection(features)

Update the selection collection.

Parameters:
Name Type Description
features ol.Collection.<ol.Feature>

the features to transform


setStyle(style, olstyle)

Set sketch style.

Parameters:
Name Type Description
style style

Style name: 'default','translate','rotate','rotate0','scale','scale1','scale2','scale3','scalev','scaleh1','scalev2','scaleh3'

olstyle ol.style.Style | Array.<ol.style.Style>