×
Namespaces

Variants
Actions

HERE Maps API - Short introduction to observable lists

From Nokia Developer Wiki
Jump to: navigation, search

The OList class in HERE Maps API is used to provide an observable list. In this article we show how to create the list and how to perform some operations on it.

new nokia.maps.util.OList ([elements])
Article Metadata
Code Example
Source file: olist.html
Tested with
Devices(s): Internet Explorer, Firefox, Opera, Google Chrome
Compatibility
Platform(s): Web browser
Dependencies: HERE Maps 2.5.3
Article
Keywords: HERE Maps, JavaScript, observable lists
Created: Maveric (21 Jun 2011)
Updated: avnee.nathani (31 Dec 2011)
Last edited: jasfox (28 Nov 2013)

Contents

Prerequisites

HERE Maps API supported web browser (basically any modern web browser)

Important note about maps credentials

Nokia provides several services options within the Maps API offering. The service is free to use, but you must obtain and use authentication and authorization credentials to use the services. Please read the Terms and Conditions and check the Pricing Plans page to decide which business model best fits your needs. Authentication requires unique Maps API credentials, namely an AppId and a token. You can get these credentials free for free following the instructions here

Implementation

The list can be manipulated by adding and removing items on it, and queries can be performed for e.g. the length of the list.

To create a new list:

 mylist = new nokia.maps.util.OList();

To add to the list (e.g. three coordinates)

    mylist.add([53.1]);
mylist.add([13.1]);
mylist.add([23.1]);

Query the length of a list:

    mylist.getLength();

This would return amount of "3" items as its result.

To clear the list from items:

    mylist.clear()

The result of getLength() for the list would return zero/no items:

    mylist.getLength();

The list can be enabled with an Observer.

addObserver (callback, [context])

To register a new observer.

API Reference definition:

Parameters: {Function} callback The callback which will be invoked after the list was modified with following arguments: (OList) oList - the OList instance itself (String) method - the name of the method which caused the triggering (Variant) element - the element which was added or deleted (Number) idx - the index of the concerned element

The callback can signalize that a rollback has occurred by returning true.

{Object} [context]: The context to use when the callback will be invoked.


Example code

A working example can be found at:

http://rawgithub.com/heremaps/examples/master/maps_api_for_javascript/advanced-examples/olist.html

For more on the HERE Maps API

Please check out the HERE Maps API full documentation and API reference here:

You may also access the interactive API explorer

This page was last modified on 28 November 2013, at 11:51.
185 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×