×
Namespaces

Variants
Actions
(Difference between revisions)

HERE Maps API - Short introduction to observable lists

From Nokia Developer Wiki
Jump to: navigation, search
rahulvala (Talk | contribs)
m (Rahulvala -)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update of Template:ArticleMetaData)
Line 2: Line 2:
 
{{Abstract|visible=false|The OList class in Nokia Maps API is used to provide an observable list. In this article we will check on how to create one and how to perform some operations on it.}}
 
{{Abstract|visible=false|The OList class in Nokia Maps API is used to provide an observable list. In this article we will check on how to create one and how to perform some operations on it.}}
 
{{ArticleMetaData
 
{{ArticleMetaData
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|platform= Web browser
 
|platform= Web browser
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by=<!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 
|update-by=[[User:avnee.nathani]]
 
|update-by=[[User:avnee.nathani]]
 
|update-timestamp=20111231
 
|update-timestamp=20111231
 +
|creationdate=20110621
 +
|author=[[User:Maveric]]
 
}}
 
}}
  

Revision as of 01:48, 2 January 2012


Article Metadata
Compatibility
Platform(s): Web browser
Article
Created: Maveric (21 Jun 2011)
Updated: avnee.nathani (31 Dec 2011)
Last edited: hamishwillee (02 Jan 2012)

Contents

Introduction

The OList class in Nokia Maps API is used to provide an observable list. In this article we will check on how to create one and how to perform some operations on it.

new nokia.maps.util.OList ([elements])

Prerequisites

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

Important about Maps credentials

Nokia provides several services options within the Maps API offering. The service is free to use, but if you complete the free registration process and obtain authentication and authorization credentials, your application will have priority access to the service and will thus avoid a potential performance penalty. Please read the Location API Business Models and Usage Restrictions 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 from the Nokia Developer API Registration page.

Implementation

The list can be manipulated by adding and removing items on it, and perform queries 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 lenght of list:

    mylist.getLength();

This would return amount of "3" items as 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

<html>
<head>
<title>Olist test</title>
<script type="text/javascript"
src="http://api.maps.nokia.com/2.0.0/jsl.js" charset="utf-8">
</script>
</head>
<body>
<div id="map" style="width: 100%; height: 100%; position: absolute;"></div>
<script type="text/javascript">
 
var map = new nokia.maps.map.Display(document.getElementById("map"), {
components: [
//behavior collection
new nokia.maps.map.component.Behavior(),
new nokia.maps.map.component.ZoomBar(),
new nokia.maps.map.component.Overview(),
new nokia.maps.map.component.TypeSelector(),
new nokia.maps.map.component.ScaleBar() ],
zoomLevel: 10,
center: [52.51, 13.4]
});
 
mylist = new nokia.maps.util.OList();
 
mylist.add([53.1]);
mylist.add([13.1]);
mylist.add([23.1]);
 
alert("Length of the list: "+mylist.getLength());
mylist.addObserver (listModified);
 
//mylist.add([53.1]);
//Comment this out to test the listener
 
function listModified()
{
alert("List was modified!");
}
</script>
 
</body>
</html>

For more on Nokia Maps API

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

You may also access the interactive Nokia Maps API playground,

Tested on

  • Google Chrome 11.0x
  • Mozilla Firefox 5.0
343 page views in the last 30 days.
×