API¶
Additionally, the common API of a module is available.
Initialization methods¶
loadMap()¶
Asynchronous method that loads a specific map from a venue.
Input:
load_options
(object): Object with the information of the map to be loaded. Its properties are:venue_id
(string): venue id.map_id
(string) [optional]: map id. Default map is called "main".
Output:
promise
(Promise): loadMap returns a promise that will be resolved if the map is loaded successfully or it will be rejected if there was a problem when loading the map.- If the promise is resolved successfully, the first argument will be an object with the
property
instance
, with the reference to the module. - If the promise is rejected, the first argument will be an error with a property
instance
with the module instance that failed to load.
- If the promise is resolved successfully, the first argument will be an object with the
property
Warning
This method is asynchronous.
Example:
isInitialized()¶
Returns true if the viewer has been initialized.
Output::
initialized
(boolean):true
if it has been initialized,false
otherwise.
Example:
isLoaded()¶
Returns true if there is a map currently loaded.
Output:
loaded
(boolean):true
if a map is completely loaded,false
otherwise.
Example:
reset()¶
unloads the current map (if any). It is necessary to call loadMap again after this.
Example:
Info methods¶
getVenueId()¶
Returns the id of the current loaded venue.
Output:
current_venue
(string|null): returns the id of the current loaded venue. If there is no venue loaded yet, it will returnnull
.
Example:
getMapId()¶
Returns the id of the current loaded map.
Output:
current_map
(string|null): returns the id of the current loaded map. If there is no map loaded yet, it will returnnull
.
Example:
getMinimapId()¶
Returns the id of the assigned minimap of the current loaded map.
Output:
minimap_id
(string|null): Returns the id of the assigned minimap of the current loaded map. If there is no map loaded yet, or there is no assigned minimap, it will returnnull
.
Example:
subscribe()¶
Allows the subscription to callbacks. This is the same as passing the callbacks when loading the module.
Input:
callback_name
(string): Any callback of the list.callback_func
(function): Function that will be called when triggered.
Output:
subscription
(Subscription): Object withunsubscribe
function. It does the same as callingunsubscribe
method, but making unnecessary to store the original reference to the subscribed function callback.
Example:
unsubscribe()¶
Removes a callback previously added with subscribe method or loading the module.
Input:
callback_name
(string): Any callback of the list.callback_func
(function): reference to the function to be removed.
Example:
getMapDescription()¶
Asynchronous method that resolves in a map description.
Output:
description
(Promise): promise that will be resolved with an object with "title" and "description".
Example:
getIconsList()¶
Returns an array with the ids of the available icons to use with the styles.
Warning
Please note that different maps might have different set of icons.
Output:
icons_list
(string[]): list with the icon ids.
Example:
getTypesList()¶
Returns an array with the ids of node types used in this map.
Warning
Please note that different maps might have different types of nodes.
Output:
types_list
(string[]): list with the types ids.
Example:
getStatesList()¶
Returns an array with the ids of the states available for a particular type of node.
Input:
type
(string): node type from which you want to obtain te states list.
Output:
states_list
(string[]): list with the states ids.
Example:
Node getters methods¶
The following methods are made to obtain the map nodes depending on their properties.
getNodeById()¶
Returns a MapViewerNode
from a given id. This can be null
if there is no node with this id.
Input:
node_id
(string): unique node identifier.
Output:
node
(MapViewerNode | null): aMapViewerNode
if the node exists. Otherwisenull
.
Example:
getNodes()¶
Generic method that allows to combine multiple filters to get a list of nodes.
Input:
filter
(Object)[optional]::** Object with the filters. If it's undefined, the method will return all the set of nodes. Its properties can be:type
(string | string[]) [optional]: type or types (union).state
(string | string[]) [optional]: state or states (union).parent
(string | string[]) [optional]: parent or parents (union).group
(string | string[]) [optional]: group or groups.intersection
(boolean) [optional]:true
for groups intersection,false
(or empty) for- groups union.
nodes
(MapViewerNode | MapViewerNode[])[optional]::** Nodes to be filtered. If it's undefined, all nodes- will be filtered.
Output:
nodes
(MapViewerNode[]): nodes that meet al filters.
Example:
getNodesByParent()¶
Returns a MapViewerNode
array with the children nodes from the desired parent.
Input:
parent_node
(string | MapViewerNode): MapViewerNode or id of the parent node.
Output:
children_nodes
(MapViewerNode[]): Array containing the node children. The array will be empty if the node does not have any children.
Example:
getNodesByType()¶
Returns an array of MapViewerNode
from a given type.
Input:
type
(string): node type.parent
(MapViewerNode | string) [optional]: If this is not included, you will get all the nodes withtype
on the map. If the parent is included, you will get all elements with the desiredtype
that are children ofparent
.
Output:
output
(MapViewerNode[]):MapViewerNode
array with the given type. The array will be empty if any node applies the condition.
Example:
getNodesByState()¶
Returns a MapViewerNode
array with the given state. The type is also needed in this case.
Input:
type
(string): Desired nodes type.state
(string): Desired nodes state.parent
(MapViewerNode | string) [optional]: If this is not included, you will get all the nodes withstate
on the map. If the parent is included, you will get all nodes with the desiredstate
that are children ofparent
.
Output:
node_array
(MapViewerNode[]):MapViewerNode
array with the given type and state. The array will be empty if any node applies the condition.
Example:
getNodesByTag()¶
Returns a MapViewerNode
array with the nodes with the required tag. If null
is introduced, it returns the node
without tag assignment.
Info
Tag "none" is equivalent to not having tag.
Input:
type
(string): Desired nodes type.style_tag
(string | null): desired style tag for the obtained nodes. This must be avalid
string (not an emptystring
), ornull
for non-tag nodes.parent
(MapViewerNode | string) [optional]: If this is not included, you will get all the nodes withstyle_tag
on the map. If the parent is included, you will get all nodes with the desiredstyle_tag
that are children ofparent
.
Output:
node_array
(MapViewerNode[]):MapViewerNode
array with the nodes that have the required style tag.
Example:
getNodesByGroups()¶
Returns a MapViewerNode
array. This method accepts multiple groups as input and has two modes:
- If
intersection
isfalse
: Returns the joint union of the nodes from the required groups. - If
intersection
istrue
: Returns the joint intersection of the nodes from the required groups.
Input:
type
(string): Desired nodes type.groups
(string | string[]): group or groups from which the nodes are required.intersection
(boolean) [optional]:false
for union,true
for intersection. Default isfalse
.parent
(MapViewerNode | string) [optional]: If this is not included, you will get all the nodes withgroups
on the map. If the parent is included, you will get all nodes with the desiredgroups
that are children ofparent
.
Output:
node_array
(MapViewerNode[]):MapViewerNode
array with the union or intersection of the nodes belonging to the required groups. The array will be empty if no node meets the conditions.
Example:
getGroupsByType()¶
Returns an object with the available types on the map, and what groups have their nodes.
getNeighbors()¶
Returns the nodes quantity count
that achieve the following requirements:
- The introduced node has to belong to a row.
- The introduced node has to be
available
orselected
. - There must be enough contiguous nodes that are
available
orselected
.
If also filter_single_seats
flag is set to true
, the following conditions need also to be achieved:
-
the returned node set cannot leave a node with state
available
orselected
without at least one adjacent node with stateavailable
orselected
, or a filterRows marked node. -
In case of achieving the above conditions, an array with the same quantity of nodes requested will be given (including the introduced node).
- In case of not achieving the above conditions, the returning array will be empty.
Warning
In case of using filter_single_seats
, remember that it is necessary to use the
method filterRows with the same quantity than count
.
Input:
node
(string | MapViewerNode): base node from which the contiguous nodes are desired.quantity
(number) [optional]: Quantity of nodes to be obtained. If no quantity is specified, it will return the full group of available seats.filter_single_seats
(boolean) [optional]: Iftrue
, returned groups will apply the stranded single seats filtering. Default esfalse
.
Output:
node_array
(MapViewerNode[]):MapViewerNode
array with the nodes that meet the requirements.
Example:
getVisibleNodes()¶
Returns an array with the nodes that are visible on the viewer viewport.
Input:
type
(string): Desired nodes type.
Output:
node_array
(MapViewerNode[]):MapViewerNode
array with the visible nodes.
Example:
getNodesAt()¶
Returns an array with the nodes that are at the specified scene position.
Input:
scene_point
(ScenePoint): Scene position where nodes are going to be searched.type
(string) [optional]: If specified, it will return only the nodes with the same type.
Output:
node_array
(MapViewerNode[]):MapViewerNode
array with the matching nodes.
Example:
getNodesOnArea()¶
Returns an array with the nodes that are at the specified scene area.
Input:
scene_area
(SceneBBox):[x, y, width, height]
, where[x,y]
is the upper left corner.type
(string) [optional]: If specified, it will return only the nodes with the same type.
Output:
node_array
(MapViewerNode[]):MapViewerNode
array with the matching nodes.
Example:
Availability methods¶
The following methods manage the elements availability.
setAvailability()¶
Sets the map availability inside a specific node array with a defined type. The nodes inside this array
will change their status to available
, while the nodes outside this array will change their status to unavailable
.
Warning
If a node has the state selected
, it will NOT change to available
if it has been included
in the node array (it will contain its state), but if it is not included in the node array, its state
will change to unavailable
, then it will be unselected.
Warning
If an element inside the array does not apply the input type (for instance, including a seat
type node
when the input type is section
), the element will be ignored.
Input:
type
(string): the action will be applied to nodes of this type.nodes
(MapViewerNode | MapViewerNodes[] | string | string[]): Element or elements that will be set asavailable
, in case they have the requiredtype
andparent
.parent
(MapViewerNode | string) [optional]: If this is not included, the action will be applied to all elements with the desiredtype
. If the parent is included, the action will be only applied to all elements with the desiredtype
and children of thisparent
.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
setAvailable()¶
Sets available
state to the specified elements with a desired type. The difference between this
method and setAvailability is that this method does not apply to the non specified elements in the input.
Warning
If a node has the state selected
, its state will not change to available
, and the
selection will be preserved.
Warning
If an element inside the array does not apply the input type (for instance, including a seat
type
node when the input type is section
), the element will be ignored.
Input:
type
(string): the action will be applied to nodes of this type.nodes
(MapViewerNode | MapViewerNodes[] | string | string[]): Element or elements that will be set asavailable
, in case they have the requiredtype
andparent
.parent
(MapViewerNode | string) [optional]: If this is not included, the action will be applied to all elements with the desiredtype
. If the parent is included, the action will be only applied to all elements with the desiredtype
and children of thisparent
.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
setUnavailable()¶
Sets unavailable
state to the specified elements with a desired type.
Warning
If an element inside the array does not apply the input type (for instance, including a seat
type
node when the input type is section
), the element will be ignored.
Input:
type
(string): the action will be applied to nodes of this type.nodes
(MapViewerNode | MapViewerNode[] | string | string[]): Element or elements that will be set asavailable
, in case they have the requiredtype
andparent
.parent
(MapViewerNode | string) [optional]: If this is not included, the action will be applied to all elements with the desiredtype
. If the parent is included, the action will be only applied to all elements with the desiredtype
and children of thisparent
.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
enable()¶
Changes the state of a node from disabled
to unavailable
. If the node's state is not disabled
, this
method will do nothing.
This method is used along with disable.
Input:
type
(string): the action will be applied to nodes of this type.nodes
(MapViewerNode | MapViewerNode[] | string | string[]): Element or elements that will be enabled, in case they have the requiredtype
andparent
.parent
(MapViewerNode | string) [optional]: If this is not included, the action will be applied to all elements with the desiredtype
. If the parent is included, the action will be only applied to all elements with the desiredtype
and children of thisparent
.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
disable()¶
Set the state of any node to disabled
. If a node was selected
, it will be unselected before
being set to disabled
. A disabled node cannot change its state unless you use enable method.
Having nodes disabled is useful in some user cases, For example:
- If you want to make sure that some nodes remains not available (
disabled
), preventing they being set it to available by accident. - If
disabled
state has no styles, disabled nodes will be invisible, so you can tell whether a node is not available in some event (disabled and invisible) or it simply has been already taken (unavailable and grey).
This method is used along with enable.
Input:
type
(string): the action will be applied to nodes of this type.nodes
(MapViewerNode | MapViewerNode[] | string | string[]): Element or elements that will be disabled, in case they have the requiredtype
andparent
.parent
(MapViewerNode | string) [optional]: If this is not included, the action will be applied to all elements with the desiredtype
. If the parent is included, the action will be only applied to all elements with the desiredtype
and children of thisparent
.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
Selection methods¶
The following methods manage the elements selection inside the map.
max_selection¶
Configures the maximum number of elements allowed to be selected. Once this number is reached
by the selection, new selections will not be allowed (and no elements will be unselected). There
is no limitation by default (Infinity
).
Input/Output:
:
- type
(Integer): maximum number of elements allowed to be selected. It is a number and
must be an integer.
Example:
hover()¶
Forces the viewer to mark a specific node or nodes as if the mouse was hovering it. This is useful when you want the viewer to react to external actions (for instance, selection outside the map).
When this method is used, the previous hovered elements will be overrided.
If you call this method without input, or null
, or an empty array, you will unhover all hovered elements.
Input:
nodes
(MapViewerNode | MapViewerNode[] | string | string[] | null): node or nodes to be set as hover.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
Warning
The method do not trigger hover
, enter
or leave
callbacks.
select()¶
Selects one or mode nodes. max selection also applies to this action. If some of the
elements cannot be selected (for instance, if its state is unavailable
), it will not be selected.
Input:
nodes
(MapViewerNode | MapViewerNodes[] | string | string[]): Elements to be selected. It can be a single node (id oMapViewerNode
) or an array of elements.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
unselect()¶
Unselects one or mode nodes. These nodes will be only unselected if their state is selected
. When
an element unselected, its state becomes available
.
Input:
nodes
(MapViewerNode | MapViewerNodes[] | string | string[]): Elements to be selected. It can be a single node (id oMapViewerNode
) or an array of elements.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
unselectAll()¶
Unselects all current selected elements (if there is any).
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
Groups methods¶
See also getNodesByGroups on node getters section.
addNodesToGroup()¶
Allows adding nodes to a certain group.
Input:
nodes
(MapViewerNode | MapViewerNodes[] | string | string[]): Nodes to be added to the group.group
(string): Name of the group.
Output:
success
(boolean): returnstrue
if success. Otherwise returnsfalse
.
Example:
removeNodesFromGroup()¶
Allows removing nodes from a group.
Input:
nodes
(MapViewerNode | MapViewerNodes[] | string | string[]): Nodes to be removed from the group.group
(string): Name of the group.
Output:
success
(boolean): returnstrue
if success. Otherwise returnsfalse
.
Example:
Filter methods¶
filterRows()¶
Filters the nodes that belong to a row that satisfy the following condition:
- A series of contiguous nodes with the state
available
orselected
cannot take part of acount
sized group.
In addition, if the parameter filter_single_seats=true
, nodes that neither satisfy
the following condition will be filtered:
- If an
available
orselected
node cannot take part of a joint with contiguous nodes without leaving anavailable
orselected
node alone.
The output of this method returns the nodes to be filtered (the action is not directly
applied) - they are the nodes that do not satisfy the condition of taking part of a count
sized group.
You can change the state to unavailable
with setUnavailable, or assign
a specific group to this joint to know if they were unavailable
previously to the filtering
process, and which were available
but do not obey the necessary conditions to be selected.
Internally these nodes are treated like filtered so the method getNeighbors works
as expected when using filter_single_seats=true
.
This also facilitates making a second filtering process if the desired quantity of seats changes. Having these nodes marked in some common group allows us to retrieve them, revert them to the initial state and filter again.
Normally this should be use with getNeighbors.
Info
One way to store which nodes have been filtered would be assigning a common group. Also you can assign a common style tag, but remember that every node can have a single tag, so you could accidentally overwrite some tag.
Input:
count
(number): Desired group size.filter_single_seats
(boolean): iftrue
, seats that can cause stranded single seats when selectingcount
seats will be filtered.parent
(string | MapViewerNode) [optional]: You can apply the filter on the children of some specific node.
Output:
success
(MapViewerNode[]): Array with the nodes to be filtered.
Example:
checkIsolatedNodes()¶
It will check if any selected
node is leaving any available
node isolated.
The node must be member of a row.
Output:
isolated
(MapViewerNode[]): Array with all isolated nodes.
Example:
Style methods¶
The following methods give utilities about how to paint nodes in the Viewer.
See also getNodesByTag on node getters section.
forceCursor()¶
Force the cursor style when the cursor is over the map. Forcing the cursor style will ignore any style relative to cursor that any state or style tag may have. You can check available native cursors here.
Input:
cursor
(string|null): if the input is astring
, cursor will be forced to use it. If the input isnull
, forced cursor will be disabled.
getStyles()¶
Returns the current styles being used. You can see more about styles here.
Output:
success
(Object): Current styles.
Example:
setStyles()¶
Overwrites the current styles configuration by a new one. You can see how to build style objects here.
Input:
styles
(StylesObject[]): This array with an style objects for every level.
Output:
success
(boolean): returnstrue
if success. Otherwise, returnsfalse
.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
setNodeCustomStyles()¶
Overrides the default styles of a node (from type > state > pseudostate > tag). This can be useful when you want specific styles for one specific node, without the need of having to generate and assign group styles.
Input:
node
(string | MapViewerNode): Target node.styles
((MapViewerStylesTag|null)[] | null): Array with the styles for each level. Passing null will reset the custom styles of that node.override
(boolean) [optional]: Iftrue
, it will replace the default styles, instead of merging with them.false
by default.
Example:
setNodesTag()¶
Sets the tag of the specified nodes.
Info
The tag "none" is equivalent to not having tag.
Input:
nodes
(string | string[] | MapViewerNode | MapViewerNode[]): Element or elements to whom the tag will be changed.style_tag
(string | null): New tag to be assigned. Passingnull
will remove the nodes tag.
Output:
success
(boolean): returnstrue
if success. Otherwise returnsfalse
.
Example:
Label methods¶
getLabel()¶
Gets the information of a specific label of a node.
Input:
node
(string | MapViewerNode): MapViewerNode or id of the node.index
(number) [optional]: Index of the label to be removed. Default is0
(first label).
Output:
Label
(Object): It has the following properties:show
(boolean):true
if the label is visible, otherwisefalse
.text
(string|null): Text to be shown as label. If is an empty string (""
), no label will be drawn. If it isnull
, the default label will be drawn. By default, it is the node id withoutS_
.size
(number|null): Text size. Ifnull
it uses5
by default.font
(string|null): font used. It can be used any valid css font family. Ifnull
it usessans-serif
by default.position
([number, number]): [x, y] scene position of the label.rotation
(number|null): label rotation in degrees. 0 by default.
addLabel()¶
Creates a new label for a node.
Input:
node
(string | MapViewerNode): MapViewerNode or id of the node to which the label will be added.label
(Object) : Same object asgetLabel()
output. Properties can be omitted and that property will use the default value.
updateLabel()¶
Updates an existing label from a node.
Input:
node
(string | MapViewerNode): MapViewerNode or id of the node to which the label will be updated.label
(Object) : Same object asgetLabel()
output. Properties can be omitted and that property will not be modified.index
(number) [optional]: Index of the label to be edited. Default is0
(first label).
removeLabel()¶
Removes an existing label from a node.
Input:
node
(string | MapViewerNode): MapViewerNode or id of the node to which the label will be removed.index
(number) [optional]: Index of the label to be removed. Default is0
(first label).
setLabels()¶
Input:
labels
(Object) : Object with node ids as key and an object with the following properties as value:text
(string|null) [optional]: Text to be shown as label. If is an empty string (""
), no label will be drawn. If isnull
, the default label will be drawn. By default, it is used the node id withoutS_
.size
(number) [optional]: Text size.5
by default.font
(string) [optional]: font used. It can be used any valid css font family,sans-serif
by default.
Example:
Navigation methods¶
The following methods manage the navigation through the map and the zoom levels.
Info
When talking about scaling factor, the reference is that if scaling_factor is equal to 1, then the seat diameter is equal to 1.
scaling_factor¶
This property contains the current scaling factor used in the map. When setting it, if the factor is greater than the maximum zoom or lower than the minimum zoom, the scaling factor will be forced to the nearer limit.
Input/Output:
scaling_factor
(number): it has to be a number greater than 0.
Example:
max_scaling_factor¶
This property contains the maximum scaling factor admited by the map.
Input/Output:
max_scaling_factor
(number): it has to be a number greater than 0.
Example:
min_scaling_factor¶
This property contains the minimum scaling factor admited by the map. Unlike max_scaling_factor, the minimum scaling factor will not be forced, but the maximum of the input value and the real value will be used.
Input/Output:
min_scaling_factor
(number): it has to be a number greater than 0.
Example:
navigation_buttons_speed¶
Allows to customize the speed of the navigation buttons binded with bindInterfaceAction method.
Input/Output:
speed
(number): it has to be a number greater than 0.
Example:
zoom_buttons_speed¶
Allows to customize the speed of the zoom buttons binded with bindInterfaceAction method.
Input/Output:
speed
(number): it has to be a number greater than 0.
Example:
focusOn()¶
Centers the viewport in the specified element (if it exists), elements, a scene position or a bounding box. In addition, a scaling factor can be specified.
If you target multiple nodes, the viewer will compute their bounding box, and focus on it.
Info
Take into account that lateral and zoom limits will be respected in the whole navigation process, even if it is forced using this method. Thus, it is possible that the element may not be exactly centered in the viewer.
Input:
target
(string | MapViewerNode | (MapViewerNode | string)[] | ScenePosition | BBox): Element to be focused on. It can be a node/nodes, id/ids, a bounding box [x,y,w,h], or scene position [x,y],scaling_factor
(number): Desired zoom to be applied. This would be the same than setting the parameter before using the scaling_factor property. If no zoom is specified, the previous scaling_factor will be maintained when targeting a ScenePosition, while targeting a node it will be adapted so viewport adjusts to the size of the node.
Example:
:
goTo()¶
Centers the viewport in the specified element (if it exists), elements, a scene position or a bounding box. In addition, a scaling factor can be specified. The transition is made with an animation.
If you target multiple nodes, the viewer will compute their bounding box, and focus on it.
It works like focusOn, but creates an animation while focusing on the target.
Info
Take into account that lateral and zoom limits will be respected in the whole navigation process, even if it is forced using this method. Thus, it is possible that the element may not be exactly centered in the viewer.
Input:
target
(string | MapViewerNode | (MapViewerNode | string)[] | ScenePosition | BBox): Element to be focused on. It can be a node/nodes, id/ids, a bounding box [x,y,w,h], or scene position [x,y],scaling_factor
(number) [optional]: Desired zoom to be applied. This would be the same as setting the parameter before using the scaling_factor property. If no zoom is specified, the previous scaling_factor will be maintained when targeting a ScenePosition, while targeting a node it will be adapted so viewport adjusts to the size of the node.time
(number) [optional]: Time in milliseconds that will take the animation. Default is 1500 milliseconds.
Output:
Example:
:
scaleBy()¶
Multiplies the current scaling factor by a number.
Input:
scaling_factor
(number): Number to be multiplied by the current scaling factor. It has to be a number greater than 0.
Example:
move()¶
Allows navigating around the map specifying a direction.
Input:
distance_in_pixels
(number): pixels moved by the camera. It has to be a number greater than 0.direction
(string): Available options are"left"
,"right"
,"up"
or"down"
.
Example:
bindInterfaceAction()¶
Binds the necessary events to a DOM element to perform certain actions on the map (zoom and navigation). This allows adding custom UI to the integrations without worrying about the events management.
Input:
html_element
(HTMLElement): HTML element where the actions will be bound.action
(string): Available options are"zoom-in"
,"zoom-out"
,"move-left"
,"move-right"
,"move-up"
and"move-down"
.
Output:
success
(boolean): returnstrue
if the action was executed successfully. Otherwise returnsfalse
.
Example:
Viewport methods¶
getContainer()¶
Returns the current container (if any) where the viewer is attached.
Output:
div_element
(HTMLDivElement | null): Returns theHTMLDivElement
where the viewer is attached,null
if there is no container.
setContainer()¶
Changes the container where the viewer is.
Info
Now, having a container it's optional
Input:
div_element
(string | HTMLDivElement | null): if the input is a string, it must be de unique id of anHTMLDivElement
. Otherwise, it must be theHTMLDivElement
itself. If it'snull
, it will remove the viewer from the DOM
Example:
open()¶
Appends the viewer to the DOM.
Example:
close()¶
Detaches the viewer from the DOM.
Example:
fromDomToScene()¶
Converts a point with dom coordinates (relatives to the map html element) to its corresponding point with scene coordinates.
Input:
dom_point
(DomPoint): array [x,y] with the html coordinates of the point relative to the map html element.
Output:
scene_point
(ScenePoint): array [x,y] with the scene point corresponding to the provided dom_point.
Example:
fromSceneToDom()¶
Converts a point with scene coordinates to its corresponding point with dom coordinates (relatives to the map html element).
Input:
scene_point
(ScenePoint): array [x,y] with the scene coordinates of the point.
Output:
dom_point
(DomPoint): array [x,y] with the dom point coordinates (relatives to the map html element) corresponding to the provided scene_point.
Example:
aspect_ratio¶
Changes or returns the Viewer aspect ratio. It only works if fixed_aspect_ratio
is true
.
Input/Output:
aspect_ratio
(number): aspect ratio from the Viewer. The value is obtained by dividing height/width. For instance, to use a 16:9 aspect ratio, the division is9/16
. This is set to9/16
by default.
Example:
limits¶
Returns a limits object that contains properties useful to control UI elements (for instance for buttons enable/disable). It gives information about the currentscaling_factor and the map limits:
Output:
limits
(Object): It has the following properties:scaling_factor
(number): current scaling_factor.zoom_in_limit
(boolean):true
if maximum zoom has been reached.zoom_out_limit
(boolean):true
if minimum zoom has been reached.left_limit
(boolean):true
if left limit has been reached.right_limit
(boolean):true
if right limit has been reached.upper_limit
(boolean):true
if up limit has been reached.lower_limit
(boolean):true
if down limit has been reached.bbox_scene
(number[]): Bounding box of the scene.bbox_limits
(number[]): Bounding box of the camera limits. Usually is the same thatbbox_scene
bounding box, but it may change with some flags.bbox_camera
(number[]): Bounding of the visible part of the scene.center_scene
(number[]): Central point of the scene.max_scaling_factor
(number): maximum scaling factor of the map.min_scaling_factor
(number): minimum scaling factor of the map. This value might change if the size of the viewportcamera_mode
(string): it can be two different modes:"fixed"
: it uses an element pf the map as a scale reference, usually represented by, at scaling factor = 1 -> "1 seat = 1 pixel". That means that at the same scaling factor, the proportions will be maintained between maps, but the bigger the map is, the lesser is the minimum scaling factor required to show the full map, having factors of less than 1. Also, at the same scaling factor, bigger viewport containers will show more map content."adaptive"
: Scaling factor = 1 represents the full map, independently of the viewport size or the map size. scaling factors cannot be less than 1. changes.
Info
Bounding boxes represents [x, y, width, height]
, where [x,y]
is the upper left corner.
Example:
Miscellaneous methods¶
has3dViews()¶
Asynchronous method that checks if a venue has 3d views material.
Input:
venue_id
(string): venue id.
Output:
promise
(Promise): returns a promise that will be resolved with a boolean, beingtrue
if the venue has 3d views, orfalse
if it does not. The promises will be rejected if there is another problem, for example if you do not have permissions to access this venue, regardless of whether the view exists or not.
Warning
This method might generate a 403 error in console if the view does not exist. This error message cannot be prevented to be shown in console, but is harmless and no javascript error is thrown.
Warning
This method is asynchronous.
Example:
has3dView()¶
Asynchronous method that checks if a specific 3d view exists.
Input:
options
(object): Object with the information of the 3d view to be checked. Its properties are:venue_id
(string): venue id.view_id
(string): view id. It is usually a seat id or a section id, and the ids, in general, match those found on a map.
Output:
promise
(Promise): returns a promise that will be resolved with a boolean, beingtrue
if the 3d view exists, orfalse
if it does not. The promises will be rejected if there is another problem, for example if you do not have permissions to access this venue, regardless of whether the view exists or not.
Warning
This method might generate a 403 error in console if the view does not exist. This error message cannot be prevented to be shown in console, but is harmless and no javascript error is thrown.
Warning
This method is asynchronous.
Example:
hasMap()¶
Asynchronous method that checks if a specific map exists.
Input:
options
(object): Object with the information of the 3d view to be checked. Its properties are:venue_id
(string): venue id.map_id
(string): map id.
Output:
promise
(Promise): returns a promise that will be resolved with a boolean, beingtrue
if the map exists, orfalse
if it does not. The promises will be rejected if there is another problem, for example if you do not have permissions to access this venue, regardless of whether the view exists or not.
Warning
This method might generate a 403 error in console if the map does not exist. This error message cannot be prevented to be shown in console, but is harmless and no javascript error is thrown.
Warning
This method is asynchronous.
Example:
getThumbnail()¶
Asynchronous method that returns an image with a preview of the panoramic view from a seat (or a section).
The returned image has a size of 256x256 pixels.
Warning
Not all venues have 3d panoramic views, so you might get an error if the image does not exist.
Input:
options
(object): Object with the information of the preview to be downloaded. Its properties are:venue_id
(string): venue id.view_id
(string): view id. It is usually a seat id or a section id, and the ids, in general, match those found in maps.
url
(boolean) [optional]:true
if you want that the promise to be resolved in a url,false
will be resolved in an image.false
by default.
Output:
promise
(Promise): If the image is downloaded successfully, thePromise
resolves with the image. If the flag url isfalse
it is resolved in an url.
Example:
getThumbnail()¶
Warning
Deprecated input. Use this input instead.
Asynchronous method that returns an image with a preview of the panoramic view from a seat (or a section).
The returned image has a size of 256x256 pixels.
Warning
Not all venues have 3d panoramic views, so you might get an error if the image does not exist.
Input
node
(string | MapViewerNode): MapViewerNode or id of the node with the panoramic view.venue_id
(string) [optional]: if a map is loaded, its venue will be used. If a venue id is specified here, it will override the map venue. If no venue is specified and no map is loaded the promise will be rejected.url
(boolean) [optional]:true
if you want that the promise to be resolved in a url,false
will be resolved in an image.false
by default.
Output
promise
(Promise): If the image is downloaded successfully, thePromise
resolves with the image. If the flag url isfalse
it is resolved in a url.
Example
Flags¶
The Viewer instance has a property called flags
that contains several properties that modify the map behavior.
They have been included separately for organization purposes.
fixed_aspect_ratio¶
Info
You can set this flag when initializing process has finished (loadModule
).
It will be preserved with every map.
Specifies the rescaling mode of the viewer.
- If
true
: The Viewer will take up the 100% of the container width, and the height will be computed multiplying the width by theaspect_ratio
. For instance, if aspect_ratio = 0.5, the height will be 500px when the Viewer container has width of 1000px. - If
false
: The Viewer will take up the 100% of the container width and height. It is important to ensure that the container has some height or it will be set as 0px.aspect_ratio
will be ignored.
Input/Output:
fixed_aspect_ratio
(boolean):true
enables the fixed_aspect_ratio mode.false
disables it. This is set totrue
by default.
Example:
variable_zoom_on_resize¶
Specifies the map behavior when there is a rescale.
- If
true
: The scaling_factor will be adjusted so the view is not modified when the viewport does. This may cause that the limits where the seat layer is shown or hide are reached. - If
false
: The scaling_factor will remain the same when there is a resize, so the smaller the viewport of the Viewer is, less map content will be seen, and vice versa.
Input/Output:
variable_zoom_on_resize
(boolean):true
enables the variable_zoom_on_resize mode.false
disables it. This is set tofalse
by default.
Example:
max_zoom_on_first_limit¶
Info
Every map has its own default value for this flag, and you can override it after
loadMap
has been resolved.
Specifies the recompute mode for the camera upper limit (minimum scaling_factor when it is far):
- If
true
: Once the first map limit is reached (for instance up/down limits for wider Viewers) the camera will not go further any more, allowing that that camera can still move to the opposite axis. - If
false
: The camera will be adjusted to the last limit, adding additional vertical and horizontal stripes to the map.
Input/Output:
max_zoom_on_first_limit
(boolean):true
enables the max_zoom_on_first_limit mode.false
disables it. This is set tofalse
by default.
Example:
automatic_selection¶
Info
You can set this flag when initializing process has finished (loadModule
).
It will be preserved with every map.
Specifies if a click on an entity causes an automatic selection (in case that its state is available
) or
automatic deselection (in case that its state is selected
).
- If
true
: When there is a click on an entity withavailable
state, it will change its state toselected
. When there is a click on an entity withselected
state, it will change its state toavailable
. The corresponding callbacks ofclick
,selected
orunselected
will be triggered. This is the recommended method for simple integrations where you could avoid usingclick
callbacks. - If
false
: Anything will be automatically selected/unselected and it will be up to the integration to use the corresponding available callbacks to define the desired logic. This is the recommended method for a more complex integration as you will have full control of the interaction.
Input/Output:
automatic_selection
(boolean):true
enables the automatic_selection mode.false
disables it. This is set totrue
by default.
Example:
automatic_hover¶
Info
You can set this flag when initializing process has finished (loadModule
).
It will be preserved with every map.
Specifies if "hover=true" must be marked automatically when the mouse is over a node. Leaving this
to false
might be useful when multiple selection is desired using methods like getNeighbors.
In this case a manual management should be done using the hover method.
Take into account that hover
, enter
and leave
callbacks will still be triggered,
even if automatic_hover
is false.
- If
true
: When the mouse is over an entity, the hover will be marked, and their corresponding styles will be used. - If
false
: The nodes will not be marked as hover (the corresponding callbacks will be still triggered). The hover method has to be used manually.
Input/Output:
automatic_hover
(boolean):true
enables the automatic_hover mode.false
disables it. This is set totrue
by default.
Example:
zooming¶
Info
You can set this flag when initializing process has finished (loadModule
).
It will be preserved with every map.
Enables or disables zooming with mouse or touch.
- If
true
: allows zooming on the map with mouse scroll or pinch. - If
false
: disables zooming on the map with scroll of pinch. You still can zoom in and out with interface buttons or other methods. Disabling it will allow scrolling on the page over the map.
Input/Output:
zooming
(boolean):true
enables zooming.false
disables it. This is set totrue
by default.
Example:
panning¶
Info
You can set this flag when initializing process has finished (loadModule
).
It will be preserved with every map.
Enables or disables panning with mouse or touch.
- If
true
: allows pannning with mouse or touch. - If
false
: disables panning on the map when using mouse or touch. You still can move with interface buttons or other methods.
Input/Output:
panning
(boolean):true
enables panning.false
disables it. This is set totrue
by default.
Example:
preserve_min_scaling_factor¶
Info
You can set this flag when initializing process has finished (loadModule
).
It will be preserved with every map.
By default, scaling_factor
is preserved while contained between min_scaling_factor
and max_scaling_factor
.
If the viewport changes, min_scaling_factor
might change, and might force scaling_factor
to change if it goes
off range. If min_scaling_factor
changes again, the map could stay zoomed.
When this flag is true
, if scaling_factor
is equal to
min_scaling_factor
, and min_scaling_factor
changes, scaling_factor
will stick to it.
- If
true
:scaling_factor
will be preserved when it is within range, except when it is equal tomin_scaling_factor
, where it will stick to it. - If
false
:scaling_factor
will be preserved when it is within range.
Input/Output:
preserve_min_scaling_factor
(boolean):true
enables it.false
disables it. This is set tofalse
by default.