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
removeEventListenerordisposeon the given object when you no longer need it.Name Type Description typestring The name of the event
handlerfunction An event handler function
opt_captureboolean optional trueindicates that the method should listen in the capture phase (bubble otherwise)opt_scopeObject 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
EventTargetobject is being disposed.Name Type Description callbackfunction The callback function.
opt_scopeObject optional An optional scope for the callback function
-
To control a look-at-point animation in screen space. Before the look-at-point can be controlled the method
H.map.ViewModel#startControlmust be invoked once. The animation can be finished viaH.map.ViewModel#endControlName Type Description moveXnumber The movement along the x-axis in pixels per second
moveYnumber The movement along the y-axis in pixels per second
moveZnumber The movement along the z-axis in zoom-levels per second
rotateXnumber The rotation around the x-axis in degrees per second
rotateYnumber The rotation around the y-axis in degrees per second
rotateZnumber The rotation around the z-axis in degrees per second
-
dispatchEvent (evt) inherited
-
This method dispatches an event on the
EventTargetobject.Name Type Description evtH.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
EventTargetmay need to override this method in order to remove references to DOM Elements and additional listeners. -
To finish the control of a look-at-point animation. See also
H.map.ViewModel#startControlandH.map.ViewModel#controlName Type Description opt_preventKineticsboolean optional Indicates whether a kinetic effect at the end of the controlled animation is prevented.
opt_adjustViewfunction(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.ILookAtDatawhich 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.Rectas bounds in case ofP2Dengine, otherwise bounds is of typeH.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
EventTargetinstance.Name Type Description typestring The name of the event
handlerfunction A previously added event handler
opt_captureboolean optional trueindicates that the method should listen in the capture phase (bubble otherwise)opt_scopeObject optional An object defining the scope for the handler function
-
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
P2Dengine type, the bounding box of the geometry is used. In case of other engine types: if the bounds type isH.geo.Polygon, then the exterior of the polygon defines visible area, otherwise the bounding box of the given bounds geometry.Name Type Description dataH.map.ViewModel.ILookAtData The values to be modified. Here are some of the main possibilities to reposition the camera at a given look-at point:
position- use existing (default) zoom and change map centerzoom- use existing (default) map center and change zoomposition&zoom- use specified position as map center and zoombounds- set center of the bounds as a new map center and calculate zoom such that bounds are visiblebounds&position- set specified position as map center and calculate zoom such that bounds are visiblebounds&zoom- set center of the bounds as a new map center and set specified zoombounds&position&zoom- ignore bounds and use specified position and zoomtilt,heading,incline- set look-at angles
opt_animateboolean | number optional A boolean indicating if an animated transition should be applied. Alternatively, a positive number representing a speed factor that's multiplied to the default animation speed computed by the rendering engine. Valid for vector engines only. Examples:
- 1.1 means 10% faster than the default animation speed.
- 0.5 means 50% slower.
Default is
false.opt_integerZoomboolean optional Indicates if the resulting zoom level should be rounded down. It is only applied in case that the LookAtData's zoom level is not specified but bounds are. This can be used to prevent blurry raster tile maps when set the "look at" to specified bounds.
Default is
false.Fires:
- H.map.ViewModel#event:update
Returns:
Type Description H.map.ViewModel this view model object -
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#controland finished by a call ofH.map.ViewModel#endControlName Type Description opt_kineticsH.util.kinetics.IKinetics optional Kinetics settings
opt_atXnumber optional The x screen coordinate at which control starts
opt_atYnumber optional The y screen coordinate at which control starts
Type Definitions
-
An Interface to describe a look-at data set.
Properties:
Name Type Argument Description positionH.geo.IPoint <optional>
This property represents the look-at position in geographical space.
zoomnumber <optional>
This property represents the zoom level. The maximum and minimum zoom levels of the current base layer are defined during its creation and might differ depending on the map layer and its specific configuration.
boundsH.geo.AbstractGeometry <optional>
This property represents the visible area.
headingnumber <optional>
This property represents the rotation angle relative to North. A positive angle increases southward. The range is from 0 to 360 but it can be restricted by the render engine capabilities. 0 - looks from the North; 90 - looks from the East; 180 - looks from the South; 270 - looks from the West.
inclinenumber <optional>
This property represents the angle between the look-at vector and normal to the surface along x-axis. The range is from -180 to +180, but it can be restricted by the render engine capabilities. 0 - no incline, 90 - left incline, -90 - right incline.
tiltnumber <optional>
This property represents the angle between the look-at vector and normal to the surface along z-axis. The range is from 0 to 90, but it can be restricted by the render engine capabilities. 0 - looks down; 90 - looks straight.