HERE Maps API - Map UI components
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot addition of Template:ArticleMetaData) |
(Avnee.nathani - Updating) |
||
| Line 1: | Line 1: | ||
| + | [[Category:Web]][[Category:Browser]][[Category:Nokia Maps]] | ||
| + | {{Abstract|This article shows how to use a static Nokia map and add interactive UI controls to it.}} | ||
| + | |||
{{ArticleMetaData | {{ArticleMetaData | ||
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] --> | |sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] --> | ||
| Line 6: | Line 9: | ||
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | |platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | ||
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | ||
| − | |dependencies= | + | |dependencies=Nokia Maps 2.1.0 |
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | |signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | ||
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| Line 23: | Line 26: | ||
}} | }} | ||
| − | + | ||
==Introduction== | ==Introduction== | ||
| − | In this article we will | + | In this article we will make a static map interactive by adding some UI control components. By default, when the map is initiated without parameters or components, it will set the coordinates to 0,0 and zoom level to zero (0). We would be adding controls like zoom bar, scale bar and map type selector. |
| − | + | ||
==Prerequisites== | ==Prerequisites== | ||
| − | + | Nokia Maps API supported device and browser (basically any modern browser) | |
==Implementation== | ==Implementation== | ||
| Line 52: | Line 54: | ||
==Example Static non-interactive map example code== | ==Example Static non-interactive map example code== | ||
| − | This would show us a map which has no presets defined, so it will default to the map origo 0,0 and zoom level minimum (0) with no possibility for the user to interact with the map: it does not respond to the user mouse click and all the UI components are removed (Zoom Bar, Scale Bar Map Type Selector). | + | This would show us a map which has no presets defined, so it will default to the map origo 0,0 and zoom level minimum (0) with no possibility for the user to interact with the map: it does not respond to the user mouse click and all the UI components are removed (Zoom Bar, Scale Bar, Map Type Selector). |
| − | Note: The authorization token is not in use in the time of writing. Please follow the Announcements section on the Ovi Maps API discussions at the project discussion board. We will be announcing when the | + | Note: The authorization token is not in use in the time of writing. Please follow the Announcements section on the Ovi Maps API discussions at the project discussion board. We will be announcing when the authorization is enabled. |
| − | + | ||
| − | + | ||
| + | <code javascript> | ||
<html> | <html> | ||
<head> | <head> | ||
<title>Static map</title> | <title>Static map</title> | ||
| − | <script src="http://api.maps. | + | <script type="text/javascript" src="http://api.maps.nokia.com/2.0.0/jsl.js" charset="utf-8"></script> |
</head> | </head> | ||
<body> | <body> | ||
<div id="map" style="width: 100%; height: 100%; position: absolute;"></div> | <div id="map" style="width: 100%; height: 100%; position: absolute;"></div> | ||
| − | <script type="text/javascript"> | + | <script type="text/javascript">nokia.maps.util.ApplicationContext.set("authenticationToken", "<Token>"); |
| − | + | ||
| − | var map = new | + | var map = new nokia.maps.map.Display(document.getElementById("map")); |
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> | ||
| − | |||
</code> | </code> | ||
| − | Example: Dynamic, | + | Example: Dynamic, interactive map with a predefined zoom level, map center point and map type |
| − | The example code | + | The example code contains HTML code and embedded JavaScript. |
| − | + | ||
| − | + | ||
| + | <code javascript> | ||
<html> | <html> | ||
<head> | <head> | ||
<title>Dynamic, interactive map</title> | <title>Dynamic, interactive map</title> | ||
| − | <script src="http://api.maps. | + | <script type="text/javascript" src="http://api.maps.nokia.com/2.0.0/jsl.js" charset="utf-8"></script> |
</head> | </head> | ||
<body> | <body> | ||
<div id="map" style="width: 100%; height: 100%; position: absolute;"></div> | <div id="map" style="width: 100%; height: 100%; position: absolute;"></div> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
| − | + | nokia.maps.util.ApplicationContext.set("authenticationToken", "<Token>"); | |
| − | + | ||
| − | var map = new | + | var map = new nokia.maps.map.Display(document.getElementById("map"), { |
components: [ | components: [ | ||
| − | new | + | new nokia.maps.map.component.Behavior(), |
| − | new | + | new nokia.maps.map.component.ZoomBar(), |
| − | new | + | new nokia.maps.map.component.Overview(), |
| − | new | + | new nokia.maps.map.component.TypeSelector(), |
| − | new | + | new nokia.maps.map.component.ScaleBar() ], |
| − | zoomLevel: | + | zoomLevel: 8, |
| − | center: [ | + | center: [19.119, 72.8957] |
}); | }); | ||
</script> | </script> | ||
| Line 108: | Line 106: | ||
Note: Authentication setting is not mandatory at the time of writing, but should be enabled later. This will be informed separately. | Note: Authentication setting is not mandatory at the time of writing, but should be enabled later. This will be informed separately. | ||
| − | ==For more on | + | ==For more on Nokia Maps API== |
| − | Please check out the | + | Please check out the Nokia Maps API full documentation and API reference here: |
| − | http://api.maps. | + | * http://api.maps.nokia.com |
| − | + | You may also access the interactive Nokia Maps API playground, | |
| − | + | * http://api.maps.nokia.com/2.1.0/playground/index.html | |
| + | |||
| + | ==Tested on== | ||
| − | Mozilla Firefox 5.0 | + | * Google Chrome 11.0x |
| + | * Mozilla Firefox 5.0 | ||
Revision as of 09:13, 5 January 2012
This article shows how to use a static Nokia map and add interactive UI controls to it.
Article Metadata
Article
Contents |
Introduction
In this article we will make a static map interactive by adding some UI control components. By default, when the map is initiated without parameters or components, it will set the coordinates to 0,0 and zoom level to zero (0). We would be adding controls like zoom bar, scale bar and map type selector.
Prerequisites
Nokia Maps API supported device and browser (basically any modern browser)
Implementation
To make the map 'intelligent', to be able to zoom it and move within the map, we need to add some components to it.
ZoomBar This will add a slider UI component, which enables the user to increase or decrease the map zoom level. The four zoom level bookmark buttons that also will appear, allow for setting predefined zoom levels.
Overview Defines a panel showing an overview of the map of the currently visible viewport.
TypeSelector Provides a user interface to change the current base map type (Satellite, Terrain, Map)
ScaleBar Defines a panel providing a scalebar. The scalebar is a ruler displaying distance measurements at different zoom levels of the map. By default, the scalebar is collapsed showing only one ruler section. When expanded, the scalebar shows more ruler sections. The measurement type can be changed from metric to imperial, which will be reflected in the distance measurements.
Example Static non-interactive map example code
This would show us a map which has no presets defined, so it will default to the map origo 0,0 and zoom level minimum (0) with no possibility for the user to interact with the map: it does not respond to the user mouse click and all the UI components are removed (Zoom Bar, Scale Bar, Map Type Selector).
Note: The authorization token is not in use in the time of writing. Please follow the Announcements section on the Ovi Maps API discussions at the project discussion board. We will be announcing when the authorization is enabled.
<html>
<head>
<title>Static map</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">nokia.maps.util.ApplicationContext.set("authenticationToken", "<Token>");
var map = new nokia.maps.map.Display(document.getElementById("map"));
</script>
</body>
</html>
Example: Dynamic, interactive map with a predefined zoom level, map center point and map type
The example code contains HTML code and embedded JavaScript.
<html>
<head>
<title>Dynamic, interactive map</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">
nokia.maps.util.ApplicationContext.set("authenticationToken", "<Token>");
var map = new nokia.maps.map.Display(document.getElementById("map"), {
components: [
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: 8,
center: [19.119, 72.8957]
});
</script>
</body>
</html>
Note: Authentication setting is not mandatory at the time of writing, but should be enabled later. This will be informed separately.
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

