Class: ViewPort

H.map.ViewPort

new H.map.ViewPort (element, opt_options)

A viewport object holds information about the HTML element in which the map is rendered. It contains the information regarding the view port size and triggers events when the size changes.

Name Type Description
element HTMLElement

The HTML element where the map is to be rendered

opt_options H.map.ViewPort.Options optional

Optional configuration parameters

Extends

Implements

Members

center H.math.Point non-null

This property holds a value indicating the current center point of the viewport.

element HTMLElement non-null

This property holds the HTML element that defines the viewport.

height number

This property holds a value indicating the height of the viewport.

margin number

This property holds a value indicating the current margin of the viewport.

padding H.map.ViewPort.Padding non-null

This property holds a value indicating the current padding of the viewport.

width number

This property holds a value indicating the width of the viewport.

Methods

addEventListener (type, handler, opt_capture, opt_scope) inherited

This method adds a listener for a specific event.

Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it.

Name Type Description
type string

The name of the event

handler function

An event handler function

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function

addOnDisposeCallback (callback, opt_scope) inherited

This method adds a callback which is triggered when the EventTarget object is being disposed.

Name Type Description
callback function

The callback function.

opt_scope Object optional

An optional scope for the callback function

dispatchEvent (evt) inherited

This method dispatches an event on the EventTarget object.

Name Type Description
evt H.util.Event | string

An object representing the event or a string with the event name

dispose () inherited

This method removes listeners from the given object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.

endInteraction (opt_preventKinetics)

This method ends an interaction and applies a kinetic movement if it was specified in a call to startInteraction()

Name Type Description
opt_preventKinetics boolean optional

A value indicating a kinetic movement at the end of the interaction is to be prevented (true or not false)

interaction (x, y, opt_bx, opt_by, opt_timestamp)

This method resolves direct screen (view port) interaction. This function modifies the current view according to values passed in by the caller.

Name Type Description
x number

viewport x coordinate

y number

viewport y coordinate

opt_bx number optional

x coordinate for the second pointer/touch if present

opt_by number optional

y coordinate for the second pointer/touch if present

opt_timestamp number optional

A known timestamp to use

removeEventListener (type, handler, opt_capture, opt_scope) inherited

This method removes a previously added listener from the EventTarget instance.

Name Type Description
type string

The name of the event

handler function

A previously added event handler

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function

resize ()

This method updates the size of the viewport to match the container size. It must be called whenever the HTML element changes size in order to update the map's viewport values.

setMargin (margin)

This method sets the margin on the viewport.

Name Type Description
margin number

A value indicating the margin used to fetch map data

Fires:
  • H.map.ViewPort#event:marginchange

setPadding (top, right, bottom, left)

This method sets a value indicating the padding of the viewport. Padding results in a shifted map center which is the visual center of the padded area.

Name Type Description
top number

A value indicating padding at the top of the viewport

right number

A value indicating padding on the right of the viewport

bottom number

A value indicating padding at the bottom of the viewport

left number

A value indicating padding on the left of the viewport

Fires:
  • H.map.ViewPort#event:paddingchange

startInteraction (modifiers, opt_kinetics)

This method starts the interaction with the view port. It should be called every time a new interaction is started, for example on mouse grab or touch start.

Name Type Description
modifiers H.math.BitMask.<!H.map.render.RenderEngine.InteractionModifiers>

Specifies what operations should performed during every interaction.

opt_kinetics H.util.kinetics.IKinetics optional

Specifies a kinetic move at the end of interaction

Type Definitions

H.map.ViewPort.Options Object

Viewport initialization options.

Properties:
Name Type Argument Description
margin number <optional>

The size in pixel of the supplemental area to render for each side of the map

padding H.map.ViewPort.Padding <optional>

The padding in pixels for each side of the map

H.map.ViewPort.Padding Object

This variable defines viewport padding.

Properties:
Name Type Description
top number

Padding at the top of the viewport (in pixels)

right number

Padding on the right of the viewport (in pixels)

bottom number

Padding at the bottom of the viewport (in pixels)

left number

Padding on the left of the viewport (in pixels)

Events

sync

Event fired when the rendered map is synchronized with the properties of the viewport.

Type:

update

Event fired when the properties of the view-port, such as padding, margin or size, change.

Type: