×
Namespaces

Variants
Actions
(Difference between revisions)

HERE Maps API - Map UI components

From Nokia Developer Wiki
Jump to: navigation, search
Maveric (Talk | contribs)
m (Maveric - - Example Static non-interactive map example code)
Maveric (Talk | contribs)
m (Maveric - - For more on Ovi Maps API)
Line 88: Line 88:
 
Please check out the Ovi Maps API full documentation and API reference here:
 
Please check out the Ovi Maps API full documentation and API reference here:
  
[link]http://api.maps.ovi.com[/link]
+
http://api.maps.ovi.com
  
 
==Tested on==
 
==Tested on==

Revision as of 13:31, 21 June 2011

Contents

Introduction

In this article we will go thru on making a static map interactive by adding some UI control components. By default, when the map is initiated empty without no parameters or components, it will default to coordinates 0,0 and zoom level of zero (0). Also there will be none of the usual UI controls, like zoom bar, scale bar and map type selector.

Prerequisites

Ovi 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 authorisation is enabled.

<html>
<head>
<title>Static map</title>
<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 100%; position: absolute;"></div>
<script type="text/javascript">
ovi.mapsapi.util.ApplicationContext.set("authenticationToken", "<Token>");
 
var map = new ovi.mapsapi.map.Display(document.getElementById("map"));
</script>
</body>
</html>

Example: Dynamic, ineractive map with a predefined zoom level, map center point and map type

The example code is full with HTML and embedded JavaScript.

<html>
<head>
<title>Dynamic, interactive map</title>
<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 100%; position: absolute;"></div>
<script type="text/javascript">
ovi.mapsapi.util.ApplicationContext.set("authenticationToken", "<Token>");
 
var map = new ovi.mapsapi.map.Display(document.getElementById("map"), {
components: [
new ovi.mapsapi.map.component.Behavior(),
new ovi.mapsapi.map.component.ZoomBar(),
new ovi.mapsapi.map.component.Overview(),
new ovi.mapsapi.map.component.TypeSelector(),
new ovi.mapsapi.map.component.ScaleBar() ],
zoomLevel: 10,
center: [52.51, 13.4]
});
</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 Ovi Maps API

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

http://api.maps.ovi.com

Tested on

Google Chrome 11.0x Mozilla Firefox 5.0

413 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.

×