Maps API for JavaScript Developer's Guide

H.map.DataModel

Class Summary

Extends: H.util.OList

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.

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

add (layer, opt_idx)

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.

set (idx, layer) : {H.map.layer.Layer}

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

removeAt (idx) : {H.map.layer.Layer}

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

remove (layer) : {boolean}

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

flush ()

This method removes all layers from the data model.

indexOf (entry) : {number}

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

get (idx) : {?}

This method retrieves the entry at the specified index.

getLength () : {number}

This method retrieves the length of the list.

asArray () : {Array<*>}

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

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

add : {H.util.OList.Event}

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

remove : {H.util.OList.Event}

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

set : {H.util.OList.Event}

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

move : {H.util.OList.Event}

Fired when an entry was moved within the list.

Class Description

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.

Constructor Details

H.map.DataModel(opt_layers)

Parameters:
 
opt_layers:
{Array=} [optional]
 
An array of layers to be added to the data model

Method Details

add (layer, opt_idx)

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.

Parameters:
 
layer:
{H.map.layer.Layer}
 
The Layer to add
opt_idx:
{number=} [optional]
 
index The index at which the new element should be inserted
Throws:
 
{H.lang.InvalidArgumentError}
 
if the given layer does not inherit H.map.layer.Layer

set (idx, layer) : {H.map.layer.Layer}

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

Parameters:
 
idx:
{number}
 
The index at which to set the layer
layer:
{H.map.layer.Layer}
 
A layer object to set
Returns:
 
{H.map.layer.Layer}
An object representing the replacement layer
Throws:
 
{H.lang.InvalidArgumentError}
 
if the given layer does not inherit H.map.layer.Layer

removeAt (idx) : {H.map.layer.Layer}

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

Parameters:
 
idx:
{number}
 
index of the layer to be removed
Returns:
 
{H.map.layer.Layer}
Throws:
 
{Error}
 
if the given index is out of bounds

remove (layer) : {boolean}

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

Parameters:
 
layer:
{H.map.layer.Layer}
 
The layer to be removed
Returns:
 
{boolean}
A value indicating whether the layer has been found and removed (true) or not (fale)

flush ()

This method removes all layers from the data model.

indexOf (entry) : {number}

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

Parameters:
 
entry:
{?}
 
The entry for which to return the index
Returns:
 
{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

get (idx) : {?}

This method retrieves the entry at the specified index.

Parameters:
 
idx:
{number}
 
The index of the entry to get, a negative index is treated as relative from the end of the list
Returns:
 
{?}
The element at the index provided by the caller
Throws:
 
{H.lang.OutOfRangeError}
 
If the given index is out of bounds

getLength () : {number}

This method retrieves the length of the list.

Returns:
 
{number}
A value indicating the length of the list as a number of items.

asArray () : {Array<*>}

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

Returns:
 
{Array<*>}
An array holding all the entries in the list

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

add: {H.util.OList.Event}

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

remove: {H.util.OList.Event}

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

set: {H.util.OList.Event}

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

move: {H.util.OList.Event}

Fired when an entry was moved within the list.

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.