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, animate)

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

getZoom () : {number}

This method returns 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)

A method to signal the begin 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)

A method to signal the end of a control operation.

addEventListener (type, handler, opt_capture, opt_scope)

This method allows to listen for specific event triggered by the object. Keep in mind, that you must removeEventListener manually or dispose an object when you no longer need it. Otherwise memory leak is possible.

removeEventListener (type, handler, opt_capture, opt_scope)

This method will removed previously added listener from the event target

dispatchEvent (evt)

This method will dispatch event on the event target object

dispose ()

Removes listeners from this 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 callback which is triggered when the object is being disposed

Events Summary

Table 2. Events
Events

update : {H.util.ChangeEvent}

Fired when this view-model's data changes

sync : {H.map.ChangeEvent}

Fired when the rendered map is synchronized with this 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 will notify the renderer of a change of its state and trigger 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 an event "sync" whenever the renderer synchronizes the requested changes to the view with it's 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, animate)

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

Parameters:
 
zoom:
{number}
 
the new zoom level
animate:
{boolean}
 

getZoom () : {number}

This method returns 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)

A method to signal the begin 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)

A method to signal 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 allows to listen for specific event triggered by the object. Keep in mind, that you must removeEventListener manually or dispose an object when you no longer need it. Otherwise memory leak is possible.

Parameters:
 
type:
{string}
 
name of event
handler:
{!Function}
 
event handler function
opt_capture:
{boolean=} [optional]
 
if set to true will listen in the capture phase (bubble otherwise)
opt_scope:
{Object=} [optional]
 
scope for the handler function

removeEventListener (type, handler, opt_capture, opt_scope)

This method will removed previously added listener from the event target

Parameters:
 
type:
{string}
 
name of event
handler:
{!Function}
 
previously added event handler
opt_capture:
{boolean=} [optional]
 
if set to true will listen in the capture phase (bubble otherwise)
opt_scope:
{Object=} [optional]
 
scope for the handler function

dispatchEvent (evt)

This method will dispatch event on the event target object

Parameters:
 
evt:
{(H.util.Event | string)}
 
event object or event name

dispose ()

Removes listeners from this 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 callback which is triggered when the object is being disposed

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

Event Details

update: {H.util.ChangeEvent}

Fired when this view-model's data changes

sync: {H.map.ChangeEvent}

Fired when the rendered map is synchronized with this 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.