Maps API for JavaScript Developer's Guide

H.map.ViewModel

Class Summary

Extends: H.util.EventTarget

Implements: H.map.IControl

This class represents a view of the map. It consists of a virtual camera and a look-at point both of which have a position in geo-space and orientation angles. The view model allows to change the values of these objects in order to move or rotate the map or zoom in and out.

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

getCameraData () : {H.map.ViewModel.CameraData}

This method returns the camera data, which is currently rendered.

setCameraData (data) : {H.map.ViewModel}

This method sets new camera data to be processed by the renderer.

setZoom (zoom, opt_animate)

This method sets a new zoom level to be processed by the renderer

getZoom () : {number}

This method retrieves the zoom level that is currently rendered.

getRequestedCameraData () : {H.map.ViewModel.CameraData}

This method returns the currently requested data.

startControl (opt_kinetics, opt_atX, opt_atY)

This method signals the start of a control operation.

control (moveX, moveY, moveZ, angleX, angleY, angleZ, opt_zoom)

A method to set the values for a continuously modification of the ViewModel on different axes. If the current render engine doesn't support certain modifications then they are ignored.

endControl (opt_preventKinetics, opt_adjustView)

This method signals the end of a control operation.

addEventListener (type, handler, opt_capture, opt_scope)

This method adds a listener for a specific event.

removeEventListener (type, handler, opt_capture, opt_scope)

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

dispatchEvent (evt)

This method dispatches an event on the EventTarget object.

dispose ()

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.

addOnDisposeCallback (callback, opt_scope)

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

Events Summary

Table 2. Events
Events

update : {H.util.ChangeEvent}

Event fired when the given view-model's data changes

sync : {H.map.ChangeEvent}

Event fired when the rendered map is synchronized with the given view-model's data

Class Description

This class represents a view of the map. It consists of a virtual camera and a look-at point both of which have a position in geo-space and orientation angles. The view model allows to change the values of these objects in order to move or rotate the map or zoom in and out.

The view model can be manipulated by using two objects: a virtual camera or the a look-at point. A virtual camera has a position and orientation (pitch, yaw and roll) in geo-space. A look-at point allows to change the postion and orientation of the virtual camera with respect to the point that is being looked at. The look-at point has a position in geo-space and orientation (heading, tilt and incline) and a distance (the distance of the camera with respect to the look-at point). Setting look-at point values influences the camera's position and orientation and vice-versa.

Modifying the view of a map is asynchronous as the view model notifies the renderer of a change in its state and triggers the renderer.

A map renderer can choose to ignore or even correct certain values depending on its capabilities. For example a 2D map renderer will ignore tilt values and correct tilt values to be 0 on the view model in order to keep the integrity of the view model.

In order to be notified of changes to the model that originate from the renderer, the view model dispatches a "sync" event whenever the renderer synchronizes the requested changes to the view with its own internal state.

Constructor Details

H.map.ViewModel()

Method Details

getCameraData () : {H.map.ViewModel.CameraData}

This method returns the camera data, which is currently rendered.

Returns:
 
{H.map.ViewModel.CameraData}
the current rendered camera data

setCameraData (data) : {H.map.ViewModel}

This method sets new camera data to be processed by the renderer.

Parameters:
 
data:
{H.map.ViewModel.CameraData}
 
the values to be modified
Returns:
 
{H.map.ViewModel}
this view model object

setZoom (zoom, opt_animate)

This method sets a new zoom level to be processed by the renderer

Parameters:
 
zoom:
{number}
 
the new zoom level
opt_animate:
{boolean=} [optional]
 
Indicates whether the zoom change is animated, defaults to false

getZoom () : {number}

This method retrieves the zoom level that is currently rendered.

Returns:
 
{number}
Current zoom level (scale)

getRequestedCameraData () : {H.map.ViewModel.CameraData}

This method returns the currently requested data.

Returns:
 
{H.map.ViewModel.CameraData}
last requested cam/view data

startControl (opt_kinetics, opt_atX, opt_atY)

This method signals the start of a control operation.

Parameters:
 
opt_kinetics:
{H.util.kinetics.IKinetics=} [optional]
 
Kinetics settings
opt_atX:
{number=} [optional]
 
x screen coordinate at which control has started
opt_atY:
{number=} [optional]
 
y screen coordinate at which control has started

control (moveX, moveY, moveZ, angleX, angleY, angleZ, opt_zoom)

A method to set the values for a continuously modification of the ViewModel on different axes. If the current render engine doesn't support certain modifications then they are ignored.

Parameters:
 
moveX:
{number}
 
The movement on x-axis as levels per millisecond where a level correlates to the distance between camera and look-at point.
moveY:
{number}
 
The movement on y-axis as levels per millisecond where a level correlates to the distance between camera and look-at point
moveZ:
{number}
 
The movement on z-axis as levels per millisecond.
angleX:
{number}
 
The rotation of on screen's x axis as degrees per millisecond.
angleY:
{number}
 
The rotation of on screen's y axis as degrees per millisecond.
angleZ:
{number}
 
The rotation of on screen's z axis as degrees per millisecond.
opt_zoom:
{number=} [optional]
 
The modification of the zoom level as levels per millisecond

endControl (opt_preventKinetics, opt_adjustView)

This method signals the end of a control operation.

Parameters:
 
opt_preventKinetics:
{boolean=} [optional]
 
A flag to indicate whether a kinetic effect is performed
opt_adjustView:
{function(H.map.ViewModel.CameraData)=} [optional]
 
An callback to adjust the final ViewModel by modifying the passed camera data.

addEventListener (type, handler, opt_capture, opt_scope)

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.

Parameters:
 
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

removeEventListener (type, handler, opt_capture, opt_scope)

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

Parameters:
 
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 oject defining the scope for the handler function

dispatchEvent (evt)

This method dispatches an event on the EventTarget object.

Parameters:
 
evt:
{(H.util.Event | string)}
 
An object representing the event or a string with the event name

dispose ()

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.

addOnDisposeCallback (callback, opt_scope)

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

Parameters:
 
callback:
{!Function}
 
The callback function.
opt_scope:
{Object=} [optional]
 
An optional scope for the callback function

Event Details

update: {H.util.ChangeEvent}

Event fired when the given view-model's data changes

sync: {H.map.ChangeEvent}

Event fired when the rendered map is synchronized with the given view-model's data

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.