This namespace contains definitions for interaction objects. These objects act as generic controls, but with the difference that interactions are not visual elements in DOM. Interactions can be attached to a DOM element, listening to DOM events and translating those events to more understandable events for the API, specially for touch or pen events.
This namespace uses Hammer API internally for make it easy to support touch and pen events and complex gestures.
Take notice that OpenLayers has it own interactions objects in the ol.interaction
namespace. Unfortunately, this objects are tied to the ol.Map object and execute
specific actions for an ol.Map object. On the contrary, the objects in this
namespace do not execute any action, the same way as controls
work.
For now viewers that show 2D data as Mapspace.ortho.Viewer
or
Mapspace.oblique.Viewer
internally uses the objects from OpenLayers
and the interactions from this namespace are only used in the Mapspace.street.Viewer
.
In a future the API could evolve to a unified interaction system for all the viewers
in order to have only one interaction system and to support more complex gestures or devices.
- Source:
- mapspace/interaction/interaction.jsdoc
Classes
- AxisInteraction
- Collection
- CollectionEvent
- Creation
- DoubleClickZoom
- Drag
- DragPan
- DragRotate
- DragZoom
- Draw
- Dynamics
- HammerGestures
- HammerGesturesHandle
- Interaction
- InteractionEvent
- KeyAxis
- KeyboardPan
- KeyboardZoom
- KeyTrigger
- Modify
- MouseClick
- MouseHover
- MouseWheelZoom
- PinchRotate
- PinchZoom
- PinchZoom2D
- Qtvr
- ScrollZoom
- Tap
- TriggerInteraction
- WheelListener
Methods
-
<static> CreationEvent(type, feature)
-
Parameters:
Name Type Description type
Mapspace.interaction.CreationEventType Event type.
feature
ol.Feature The feature created.
- Source:
- mapspace/events.js
-
<static> defaults(element)
-
Return an object with names of default interactions as keys and
Mapspace.interaction.Interaction
as properties. The object contains this interaction keys:- mouseHover
- mouseClick
- mouseDrag
- touchView
- pinch
- scrollZoom
Parameters:
Name Type Description element
Element Element to listen for events.
- Source:
- mapspace/interaction/defaults.js
Returns:
- Type
- Object.<string, Mapspace.interaction.Interaction>
-
<static> defaultsOpenlayers( [opt_options])
-
Return a collection of interaction objects to be used internally in Ortho and Oblique/Global viewers, viewers that are based on Openlayers.
Parameters:
Name Type Argument Description opt_options
olx.interaction.DefaultsOptions <optional>
Defaults options.
- Source:
- mapspace/interaction/defaults.js
Returns:
A collection of interactions to be used with the ol.Map constructor's interactions option.
- Type
- ol.Collection.<ol.interaction.Interaction>
-
<static> ModifyEvent(type, features)
-
Parameters:
Name Type Description type
Mapspace.interaction.ModifyEventType Event type.
features
Array.<ol.Feature> Array of features modified.
- Source:
- mapspace/events.js
Type Definitions
-
CollectionEventType
-
Types of events for a
Mapspace.interaction.Collection
.Name Value Description Mapspace.interaction.CollectionEventType.STARTED started Triggered when any interaction has started. Mapspace.interaction.CollectionEventType.ENDED ended Triggered when any interaction has ended. Mapspace.interaction.CollectionEventType.PARAMETERCHANGED parameterchanged Triggered when any interaction paramater has changed. A static parameter is the one that do not change over time. A dynamics parameter is one that can change or not in time due to velocity and friction once it is started at an initial value. Mapspace.interaction.CollectionEventType.ACTIVECHANGED change:active' Triggered when the active state of any interaction changes - Source:
- mapspace/enums.js
-
ComposedInteraction
-
AxisInteraction with extra properties to work as composed.
- Source:
- mapspace/typedefs.js
Properties:
Name Type Description instance
Mapspace.interaction.AxisInteraction Interaction instance.
dynamics
Mapspace.interaction.Dynamics Dynamics parameters.
parameterDynamicsHandler
function Handler for the ParameterChanged event.
-
ComposedReturn
-
ComposedReturn is an object with the result of data of composing AxisInteraction parameters.
- Source:
- mapspace/typedefs.js
Properties:
Name Type Description parameters
Object.<string, number> an object with the parameters.
changing
boolean if the values are changing.
-
CreationEventType
-
Type of interaction produced by a
Mapspace.interaction.Creation
.Name Value Description Mapspace.interaction.CreationEventType.CREATIONSTART creationstart Mapspace.interaction.CreationEventType.CREATIONCHANGE creationchange Mapspace.interaction.CreationEventType.CREATIONEND creationend - Source:
- mapspace/enums.js
-
CreationOptions
-
Options for a
Mapspace.interaction.Creation
.- Source:
- mapspace/typedefs.js
Properties:
Name Type Description element
Element | undefined The DOM element where the events are listened to.
active
boolean | undefined If the interaction must be set to active or not.
maxPoints
Mapspace.interaction.PointerType | undefined The number of points that will trigger a DrawEnd event.
viewer
Mapspace.Viewer | undefined The viewer in which interaction must execute its actions.
layer
Mapspace.layer.Vector | undefined The layer with the features that can be modified by this interaction.
type
ol.geom.GeometryType | undefined The type of geometries to create. By default they are POINT.
interactionStyle
ol.style.Style | undefined The style to use for extra features that show where snap will occur.
useDepthmap
boolean | undefined If true the depthmap will be used to locate vertex of the geometries created. For lines each vertex in the line will be located at different elevations. For polygons all the vertex will use the elevation of the first vertex. If depthmap do not exist then the creation of the geometry will use the elevation at the camera shot point as elevation. By default is true.
-
DragOptions
-
Options for a
Mapspace.interaction.Drag
.- Source:
- mapspace/typedefs.js
Properties:
Name Type Description element
Element | undefined The DOM element where the events are listened to.
active
boolean | undefined If the interaction must be set to active or not.
pointerType
Mapspace.interaction.PointerType | undefined Type of pointer.
friction
number | undefined Friction.
maxFrictionTime
number | undefined Max friction time.
-
DrawOptions
-
Options for a
Mapspace.interaction.Draw
.- Source:
- mapspace/typedefs.js
Properties:
Name Type Description element
Element | undefined The DOM element where the events are listened to.
active
boolean | undefined If the interaction must be set to active or not.
maxPoints
Mapspace.interaction.PointerType | undefined The number of points that will trigger a DrawEnd event.
-
InteractionEventType
-
Types of events for a
Mapspace.interaction.Interaction
.Name Value Description Mapspace.interaction.InteractionEventType.STARTED started Triggered when the interaction has started. Mapspace.interaction.InteractionEventType.ENDED ended Triggered when the interaction has stopped. Mapspace.interaction.InteractionEventType.PARAMETERCHANGED parameterchanged Triggered when a parameter in an interaction changes. A static parameter is the one that do not change over time. A dynamics parameter is one that can change or not in time due to velocity and friction once it is started at an initial value. Mapspace.interaction.InteractionEventType.ACTIVECHANGED change:active Triggered when the active state of the interaction changes - Source:
- mapspace/enums.js
-
InteractionOptions
-
Options for a
Mapspace.interaction.Interaction
.- Source:
- mapspace/typedefs.js
Properties:
Name Type Description element
Element | undefined The DOM element where the events are listened to.
active
boolean | undefined If the interaction must be set to active or not.
-
InteractionStatus
-
Interaction status properties.
- Source:
- mapspace/typedefs.js
Properties:
Name Type Description instance
Mapspace.interaction.Interaction Interaction instance.
parameterChangedHandler
function The handler for the parameter changed events.
-
InteractionType
-
Type of interaction produced by a
Mapspace.interaction.Interaction
.Name Value Description Mapspace.interaction.InteractionType.DRAWDOWN DrawDown Mapspace.interaction.InteractionType.DRAWUP DrawUp Mapspace.interaction.InteractionType.DRAWCLICK DrawClick Mapspace.interaction.InteractionType.DRAWMOVE DrawMove Mapspace.interaction.InteractionType.DRAG Drag Mapspace.interaction.InteractionType.KEYAXIS KeyAxis Mapspace.interaction.InteractionType.TAP Tap Mapspace.interaction.InteractionType.SCROLLZOOM ScrollZoom Mapspace.interaction.InteractionType.KEYTRIGGER KeyTrigger Mapspace.interaction.InteractionType.MOUSECLICK MouseClick Mapspace.interaction.InteractionType.MOUSEHOVER MouseHover Mapspace.interaction.InteractionType.QTVR Qtvr Mapspace.interaction.InteractionType.PINCHZOOM PinchZoom - Source:
- mapspace/enums.js
-
KeyOptions
-
Options for a
Mapspace.interaction.KeyAxis
.- Source:
- mapspace/typedefs.js
Properties:
Name Type Description element
Element | undefined The DOM element where the events are listened to.
active
boolean | undefined If the interaction must be set to active or not.
keyCode
number | undefined Key which activates the interaction when pressed.
parameter
string | undefined The parameter to be controlled (e.g.
x
,y
orzoom
).velocity
number | undefined Velocity at which the parameter changes. Use a negative number for opposite direction.
friction
number | undefined Friction at which the parameter stops.
-
ModifyEventType
-
Type of interaction produced by a
Mapspace.interaction.Modify
.Name Value Description Mapspace.interaction.ModifyEventType.MODIFYSTART modifystart Mapspace.interaction.ModifyEventType.MODIFYCHANGE modifychange Mapspace.interaction.ModifyEventType.MODIFYEND modifyend - Source:
- mapspace/enums.js
-
ModifyOptions
-
Options for a
Mapspace.interaction.Modify
.- Source:
- mapspace/typedefs.js
Properties:
Name Type Description element
Element | undefined The DOM element where the events are listened to.
active
boolean | undefined If the interaction must be set to active or not.
maxPoints
Mapspace.interaction.PointerType | undefined The number of points that will trigger a DrawEnd event.
viewer
Mapspace.Viewer | undefined The viewer in which interaction must execute its actions.
layer
Mapspace.layer.Vector | undefined The layer with the features that can be modified by this interaction.
features
Array.<ol.Feature> | undefined The features inside the layer that can be modified by this interaction. If not set then any of the features in the layer can be modified.
interactionStyle
ol.style.Style | undefined The style to use for extra features that show where snap will occur.
snapVertexRatio
number | undefined Value in [0, 0.5) range that represent the percentage of a segment to snap to the nearest vertex. If point is closer than ratio * len (where len is the length of the segment) then the vertex is used instead of a point inside the segment. By default is 0.1.
vertical
boolean | undefined If this interaction must be restricted to modify Z values of features (Z values are Y values in local coordinates). By default is false. If false changes can be made only in the same Z plane of current local coordinates for each vertex.
useDepthmap
boolean | undefined If true the depthmap will be used to locate vertex when modifying them using Shift + Click on them. For lines each vertex in the line will be located at different elevations. For polygons all the vertex will use the elevation of the first vertex. If depthmap do not exist then the modified vertex will use the elevation at the camera shot point as elevation. By default is true.
-
PointerType
-
Types of pointers in an interaction.
Name Value Description Mapspace.interaction.PointerType.MOUSE mouse Using the mouse. Mapspace.interaction.PointerType.TOUCH touch Using fingers in a touch surface. - Source:
- mapspace/enums.js
-
Property
-
Properties of a
Mapspace.interaction.Interaction
.Name Value Description Mapspace.interaction.Property.ACTIVE active If the interaction is active. - Source:
- mapspace/enums.js
-
QtvrOptions
-
Options for a
Mapspace.interaction.Qtvr
.- Source:
- mapspace/typedefs.js
Properties:
Name Type Description element
Element | undefined The DOM element where the events are listened to.
active
boolean | undefined If the interaction must be set to active or not.
speed
number | undefined Speed.
friction
number | undefined Friction.
maxFrictionTime
number | undefined Max friction time.
-
ScrollZoomOptions
-
Options for a
Mapspace.interaction.ScrollZoom
.- Source:
- mapspace/typedefs.js
Properties:
Name Type Description element
Element | undefined The DOM element where the events are listened to.
active
boolean | undefined If the interaction must be set to active or not.
maxFrictionTime
number | undefined Max friction time.
zoomDelta
number | undefined Zoom delta.