Powered by Zoomin Software. For more details please contactZoomin

HERE Maps API for JavaScript - API Reference

Product category
Technology
Doc type
Version
Product lifecycle
This publication

HERE Maps API for JavaScript - API Reference: Class: ViewModel

Table of Contents

Class: ViewModel

Class: ViewModel

H.map.ViewModel

new H.map.ViewModel ()

This class represents a view of the map. It consists of a look-at point which has a position in geo-space and orientation angles (heading, tilt and incline). The view model allows to change the values of this object in order to move or rotate the map or zoom in and out.

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.

Extends

Implements

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.

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

control (moveX, moveY, moveZ, rotateX, rotateY, rotateZ)

To control a look-at-point animation in screen space. Before the look-at-point can be controlled the method H.map.ViewModel#startControl must be invoked once. The animation can be finished via H.map.ViewModel#endControl

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.

endControl (opt_preventKinetics, opt_adjustView)

To finish the control of a look-at-point animation. See also H.map.ViewModel#startControl and H.map.ViewModel#control

Name Type Description
opt_preventKinetics boolean optional

Indicates whether a kinetic effect at the end of the controlled animation is prevented.

opt_adjustView function(H.map.ViewModel.ILookAtData) optional

A custom function to adjust the final view. It receives the last requested look-at data from the view model and has to return a possibly modified H.map.ViewModel.ILookAtData which is used instead.

Example
//prevent kinetics
viewModel.endControl(true);

//prevent kinetics and set adjusted view
viewModel.endControl(true, function(requested) {
  requested.zoom = Math.round(requested.zoom);
});

getLookAtData ()H.map.ViewModel.ILookAtData

This method retrieves the current rendered look-at data. It returns H.geo.Rect as bounds in case of P2D engine, otherwise bounds is of type H.geo.Polygon.

Returns:
Type Description
H.map.ViewModel.ILookAtData The current rendered look-at data

removeEventListener (type, handler, opt_capture, opt_scope) inherited

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

setLookAtData (data, opt_animate, opt_integerZoom)H.map.ViewModel

To set new look-at data for the view model. This method supports any type of geometry. In case of P2D engine type, the bounding box of the geometry is used. In case of other engine types: if the bounds type is H.geo.Polygon, then the exterior of the polygon defines visible area, otherwise the bounding box of the given bounds geometry.

Fires:
  • H.map.ViewModel#event:update
Returns:
Type Description
H.map.ViewModel this view model object

startControl (opt_kinetics, opt_atX, opt_atY)

To start the controlling of the look-at-point animation. After this method was invoked, the look-at-point animation can be controlled by several calls of H.map.ViewModel#control and finished by a call of H.map.ViewModel#endControl

Type Definitions

H.map.ViewModel.ILookAtData Object

An Interface to describe a look-at data set.

Properties:
Was this article helpful?
TitleResults for “How to create a CRG?”Also Available inAlert