Class: DataModel

H.map.DataModel

new H.map.DataModel (opt_layers)

This class represents the data model of the map. It holds a list of layers that are rendered by map's RenderEngine. The class listens to update events from layers and dispatches them to the RenderEngine.

Name Type Description
opt_layers Array optional

An array of layers to be added to the data model

Extends

Methods

add (layer, opt_idx) inherited overrides

This method adds a layer to the data model, ensuring that layers are displayed on the map following the order in which they were added.

Name Type Description
layer H.map.layer.Layer

The Layer to add

opt_idx number optional

index The index at which the new element should be inserted

Fires:
Throws:

if the given layer does not inherit H.map.layer.Layer

Type
H.lang.InvalidArgumentError

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

asArray ()Array.<*> inherited

This method retrieves all the entries held in the list as an array.

Returns:
Type Description
Array.<*> An array holding all the entries in the list

dispatchEvent (evt) inherited overrides

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.

flush () inherited overrides

This method removes all layers from the data model.

get (idx)? inherited

This method retrieves the entry at the specified index.

Name Type Description
idx number

The index of the entry to get, a negative index is treated as relative from the end of the list

Throws:

If the given index is out of bounds

Type
H.lang.OutOfRangeError
Returns:
Type Description
? The element at the index provided by the caller

getLength ()number inherited

This method retrieves the length of the list.

Returns:
Type Description
number A value indicating the length of the list as a number of items.

indexOf (entry)number inherited

This method retrieves the index of the first object in this list that is identical to the object supplied by the caller.

Name Type Description
entry ?

The entry for which to return the index

Returns:
Type Description
number The index of the first matching entry in this list or -1 if the entry provided by the caller is not found in the list

remove (layer)boolean inherited overrides

This method removes a layer, which means that the layer is removed from the map.

Name Type Description
layer H.map.layer.Layer

The layer to be removed

Fires:
Returns:
Type Description
boolean A value indicating whether the layer has been found and removed (true) or not (false)

This method removes layer with the given index. This will effectively remove the layer from the map.

Name Type Description
idx number

index of the layer to be removed

Throws:

if the given index is out of bounds

Type
Error
Returns:
Type Description
H.map.layer.Layer

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

This method sets (replaces) a layer at the index specified by the caller.

Name Type Description
idx number

The index at which to set the layer

layer H.map.layer.Layer

A layer object to set

Fires:
Throws:

if the given layer does not inherit H.map.layer.Layer

Type
H.lang.InvalidArgumentError
Returns:
Type Description
H.map.layer.Layer An object representing the replacement layer

Events

add inherited

Event fired when an entry has been added to the list.

Type:

move inherited

Fired when an entry was moved within the list.

Type:

remove inherited

Event fired when an entry has been removed from the list.

Type:

set inherited

Event fired when an entry has been set in the list.

Type: