new mapInteractor(args) → {geo.mapInteractor}
- Description:
The mapInteractor class is responsible for handling raw events from the browser and interpreting them as map navigation interactions. This class will call the navigation methods on the connected map, which will make modifications to the camera directly.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
args |
geo.mapInterator.spec | Interactor specification object. |
Returns:
- Type
- geo.mapInteractor
Extends
Members
idle
- Description:
Getter for the idle state. Read only.
- Source:
- Inherited From:
Properties:
Name | Type | Description |
---|---|---|
idle |
boolean |
|
Getter for the idle state. Read only.
(inner) m_queue
- Description:
Store queued map navigation commands (due to throttling) here { kind: 'move' | 'wheel', // what kind of mouse action triggered this method: function () {}, // the throttled method scroll: {x: ..., y: ...} // accumulated scroll wheel deltas }
- Source:
Store queued map navigation commands (due to throttling) here { kind: 'move' | 'wheel', // what kind of mouse action triggered this method: function () {}, // the throttled method scroll: {x: ..., y: ...} // accumulated scroll wheel deltas }
Methods
addAction(action, toEndopt)
- Description:
Add an action to the list of handled actions.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
action |
object | An object defining the action. This must have action and input properties, and may have modifiers, name, and owner. Use action, name, and owner to make this entry distinct if it will need to be removed later. |
|
toEnd |
boolean |
<optional> |
The action is added at the beginning of the actions list unless truthy. Earlier actions prevent later actions with similar input and modifiers. |
addPromise(promise) → {this}
- Description:
Add a new promise object preventing idle event handlers from being called until it is resolved.
- Source:
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
promise |
Promise | A promise object. |
Returns:
- Type
- this
cancel(actionnullable, keepQueueopt) → {boolean}
- Description:
Immediately cancel an ongoing action.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
action |
string |
<nullable> |
The action type, if |
keepQueue |
boolean |
<optional> |
If truthy, keep the queue event if an action is canceled. |
Returns:
Set if an action was canceled.
- Type
- boolean
destroy()
- Description:
Public method that unbinds all events.
- Source:
geoIsOn(event, handleropt) → {boolean}
- Description:
Report if an event handler is bound to this object.
- Source:
- Inherited From:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | Array.<string> | An event or list of events to check. |
|
handler |
function |
<optional> |
A function that might be bound. If
|
Returns:
true if any of the specified events are bound to the specified handler.
- Type
- boolean
geoOff(eventopt, argopt, nullable) → {this}
- Description:
Remove handlers from one event or an array of events. If no event is provided all handlers will be removed.
- Source:
- Inherited From:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | Array.<string> |
<optional> |
An event or a list of events from
|
arg |
function | Array.<function()> |
<optional> <nullable> |
A function or array of functions to remove from the events or a falsy value to remove all handlers from the events. |
Returns:
- Type
- this
geoOn(event, handler) → {this}
- Description:
Bind an event handler to this object.
- Source:
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
event |
string | An event from |
handler |
function | A function that is called when |
Returns:
- Type
- this
geoOnce(event, handler) → {function}
- Description:
Bind an event handler to this object that will fire once and then deregister itself.
- Source:
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
event |
string | An event from |
handler |
function | A function that is called when |
Returns:
The actual bound handler. This is a wrapper around the handler that was passed to the function.
- Type
- function
geoTrigger(event, argsopt) → {this}
- Description:
Trigger an event (or events) on this object and call all handlers.
- Source:
- Inherited From:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | Array.<string> | An event or list of events from
|
|
args |
object |
<optional> |
Additional information to add to the
|
Returns:
- Type
- this
hasAction(action, name, owner) → {object|null}
- Description:
Check if an action is in the actions list. An action matches if the action, name, and owner match. A null or undefined value will match all actions. If using an action object, this is the same as passing (action.action, action.name, action.owner).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
action |
object | string | Either an action object or the name of an action. |
name |
string | Optional name associated with the action. |
owner |
string | Optional owner associated with the action. |
Returns:
The first matching action or null.
- Type
- object | null
hasTouchSupport() → {boolean}
- Description:
Check if this browser has touch support. Copied from https://github.com/hammerjs/touchemulator under the MIT license.
- Source:
Returns:
true
if there is touch support.
- Type
- boolean
keyboard(newValueopt) → {object|this}
- Description:
Get/set current keyboard information.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
newValue |
object |
<optional> |
Either a object with new options for the
keyboard actions or |
Returns:
Either the current keyboard options or this mapInteractor class instance.
- Type
- object | this
map(valopt) → {geo.map|this}
- Description:
Get or set the map for this interactor, adds draw region layer if needed.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
val |
geo.map |
<optional> |
Either a new map object for |
Returns:
Either the current map object or the mapInteractor class instance.
- Type
- geo.map | this
modified() → {this}
- Description:
Update the timestamp to the next global timestamp value.
- Source:
- Inherited From:
Returns:
- Type
- this
mouse() → {object}
- Description:
Get current mouse information.
- Source:
Returns:
The current mouse state.
- Type
- object
onIdle(handler) → {this}
- Description:
Bind a handler that will be called one time when all internal promises are resolved. If there are no outstanding promises, this is invoked synchronously.
- Source:
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
handler |
function | A function taking no arguments. |
Returns:
- Type
- this
options(opts) → {geo.mapInteractor.spec|this}
- Description:
Gets/sets the options object for the interactor.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
opts |
geo.mapInteractor.spec | Options to set. |
Returns:
- Type
- geo.mapInteractor.spec | this
pause(valueopt) → {boolean|this}
- Description:
Get or set the pause state of the interactor, which ignores all native mouse and keyboard events.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
boolean |
<optional> |
The pause state to set or undefined to return the current state. |
Returns:
The current pause state or this class instance.
- Type
- boolean | this
removeAction(action, name, owner) → {number}
- Description:
Remove all matching actions. Actions are matched as with hasAction.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
action |
object | string | Either an action object or the name of an action. |
name |
string | Optional name associated with the action. |
owner |
string | Optional owner associated with the action. |
Returns:
The number of actions that were removed.
- Type
- number
removePromise(promise) → {this}
- Description:
Mark a promise as no longer required to resolve before the idle state is reached.
- Source:
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
promise |
Promise | A promise object. |
Returns:
- Type
- this
retriggerMouseMove()
- Description:
Retrigger a mouse movement with the current mouse state.
- Source:
Fires:
simulateEvent(type, options) → {mapInteractor}
- Description:
Simulate a DOM mouse event on connected map. Not all options are required for every event type.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type |
string | Event type |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object | Options for the simulated event. Properties
|
Returns:
- Type
- mapInteractor
(protected) springBack(initialVelocity, origAction)
- Description:
Start up a spring back action when the map bounds are out of range. Not to be user callable.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
initialVelocity |
boolean | Truthy if the mouse's current velocity should be used as the initial velocity. False to assume no initial velocity. |
origAction |
object | The original action that started the spring back. If this was a zoom action, the spring back includes zoom; otherwise it only includes panning. |
state() → {geo.interactorState}
- Description:
Get the current interactor state.
- Source:
Returns:
- Type
- geo.interactorState
timestamp() → {number}
- Description:
Get time.
- Source:
- Inherited From:
Returns:
The timestamp. This is 0 if the timestamp has never been modified.
- Type
- number
(inner) debounced_zoom() → {function}
- Description:
Private wrapper around the map zoom method that is debounced to support discrete zoom interactions.
- Source:
Returns:
A function to handle zooms that debounces such events. This function is passed the zoom level and the mouse state.
- Type
- function
Type Definitions
spec
- Description:
Map Interactor specification.
- Source:
Properties:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
throttle |
number |
<optional> |
30
|
Mouse events are throttled so that an event occurs no more often that this number of milliseconds. |
|||||||||||||||||||||||||||||||||||
discreteZoom |
boolean | number |
<optional> |
false
|
If |
|||||||||||||||||||||||||||||||||||
actions |
Array.<geo.actionRecord> |
<optional> |
The list of available actions. See the code for the full default list. |
||||||||||||||||||||||||||||||||||||
click |
object |
<optional> |
An object specifying if click events should be handled. Properties
|
||||||||||||||||||||||||||||||||||||
keyboard |
object |
<optional> |
An object describing which keyboard events are handled. Properties
|
||||||||||||||||||||||||||||||||||||
alwaysTouch |
boolean |
<optional> |
false
|
If true, add touch support even if the browser doesn't apepar to be touch-aware. |
|||||||||||||||||||||||||||||||||||
wheelScaleX |
number |
<optional> |
1
|
A scale multiplier for horizontal wheel interactions. |
|||||||||||||||||||||||||||||||||||
wheelScaleY |
number |
<optional> |
1
|
A scale multiplier for vertical wheel interactions. |
|||||||||||||||||||||||||||||||||||
zoomScale |
number |
<optional> |
1
|
This affects how far the mouse must be
dragged to zoom one level. Roughly, the mouse must move |
|||||||||||||||||||||||||||||||||||
rotateWheelScale |
number |
<optional> |
0.105
|
When the mouse wheel is used for rotation, this is the number of radians per wheel step. |
|||||||||||||||||||||||||||||||||||
zoomrotateMinimumRotation |
number |
<optional> |
0.087
|
The minimum angle of
rotation in radians before a |
|||||||||||||||||||||||||||||||||||
zoomrotateReverseRotation |
number |
<optional> |
0.698
|
The minimum angle of
rotation (in radians) before the |
|||||||||||||||||||||||||||||||||||
zoomrotateMinimumZoom |
number |
<optional> |
0.05
|
The minimum zoom factor
change (increasing or desceasing) before the |
|||||||||||||||||||||||||||||||||||
zoomrotateMinimumPan |
number |
<optional> |
5
|
The minimum number of pixels
before the |
|||||||||||||||||||||||||||||||||||
touchPanDelay |
number |
<optional> |
50
|
The touch pan delay prevents a touch pan event from immediately following a rotate (including zoom) event. No touch pan event is processed within this number of milliseconds of a non-pan touch event. |
|||||||||||||||||||||||||||||||||||
momentum |
object |
<optional> |
Enable momentum when panning and zooming. Properties
|
||||||||||||||||||||||||||||||||||||
spring |
object |
<optional> |
Enable spring clamping to screen edges. Properties
|
||||||||||||||||||||||||||||||||||||
zoomAnimation |
object |
<optional> |
Enable zoom animation for both discrete and continuous zoom. Properties
|
Map Interactor specification.
Type:
- object