Namespaces
Variants
Actions
(Difference between revisions)

HERE Maps API - How to draw a circle

Jump to: navigation, search
m (Jasfox - Need token.)
m (Jasfox - Updated example to use Nokia Maps API 2.2)
Line 51: Line 51:
 
==Example code==
 
==Example code==
  
<code java>
+
<code javascript>
<html>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
+
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript"
+
    <head>
    src="http://api.maps.nokia.com/2.0.0/jsl.js" charset="utf-8">
+
      <title>Circle</title>
</script>
+
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
+
      <script type="text/javascript"
<body>
+
            src="http://api.maps.nokia.com/2.2.0/jsl.js" charset="utf-8">
<div id="map" style="width:100%; height:80%;"></div>
+
        </script>
</body>
+
    </head>
<script type="text/javascript">
+
    <body>
+
 
+
        <div id="mapContainer" style="z-index: -1; left:0px; top:0px; width: 100%; height: 80%; position: absolute;"></div>
var map= new nokia.maps.map.Display(document.getElementById("map"),  // new instance of  
+
        <script type="text/javascript">
 +
/////////////////////////////////////////////////////////////////////////////////////
 +
// Don't forget to set your API credentials
 +
//
 +
// Replace with your appId and token which you can obtain when you
 +
// register on http://api.developer.nokia.com/
 +
//
 +
nokia.Settings.set( "appId", "YOUR APP ID GOES HERE");
 +
nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");
 +
 +
nokia.Settings.set( "appId", "zauRRhpkbUIPpq6HC97j");
 +
nokia.Settings.set( "authenticationToken", "LxwmSPEsGhvo-n-An5Cn7A");
 +
 +
//
 +
/////////////////////////////////////////////////////////////////////////////////////
 +
 
 +
var map= new nokia.maps.map.Display(document.getElementById("mapContainer"),  // new instance of  
 
{
 
{
 
   
 
   
Line 77: Line 93:
 
   
 
   
 
draw_Circle();
 
draw_Circle();
 
+
 
   
 
   
 
  function draw_Circle(loop){
 
  function draw_Circle(loop){
Line 91: Line 107:
 
}
 
}
 
));
 
));
  }
+
  }
 
+
+
 
</script>
 
</script>
 
</body>
 
</body>
</html>
+
</html></code>
</code>
+
  
 
==Screenshot==
 
==Screenshot==

Revision as of 16:20, 13 April 2012

This article explains how to draw a circle on Nokia Maps.

MultiMediaTile.png
MultiMediaTile.png
Article Metadata

Compatibility
Platform(s): Web browser
Dependencies: Nokia Maps 2.1.0

Article
Created: Maveric (21 Jun 2011)
Updated: avnee.nathani (31 Dec 2011)
Last edited: jasfox (13 Apr 2012)

Contents

Prerequisites

Nokia 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 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 free from the Nokia Developer API Registration page.

Implementation

The API definition:

new nokia.maps.map.Circle (center, radius, props)

In the example below, we will create new circles with an increasing radius and add them all one by one to the map display in a loop.

Example code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Circle</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript"
src="http://api.maps.nokia.com/2.2.0/jsl.js" charset="utf-8">
</script>
</head>
<body>
 
<div id="mapContainer" style="z-index: -1; left:0px; top:0px; width: 100%; height: 80%; position: absolute;"></div>
<script type="text/javascript">
/////////////////////////////////////////////////////////////////////////////////////
// Don't forget to set your API credentials
//
// Replace with your appId and token which you can obtain when you
// register on http://api.developer.nokia.com/
//
nokia.Settings.set( "appId", "YOUR APP ID GOES HERE");
nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");
 
nokia.Settings.set( "appId", "zauRRhpkbUIPpq6HC97j");
nokia.Settings.set( "authenticationToken", "LxwmSPEsGhvo-n-An5Cn7A");
 
//
/////////////////////////////////////////////////////////////////////////////////////
 
var map= new nokia.maps.map.Display(document.getElementById("mapContainer"), // new instance of
{
 
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': 4,
'center':[19.119, 72.8957]
});
 
draw_Circle();
 
 
function draw_Circle(loop){
map.objects.add(new nokia.maps.map.Circle(
// Place the circle center here
[19.15, 73.91],
// Radius of 8000 meters
4000,
{
color: "#829f",
fillColor: "#2387",
width: 100
}
));
}
</script>
</body>
</html>

Screenshot

NokiaMapsCircle.png

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 with

  • Google Chrome 11.0x
  • Mozilla Firefox 5.0
499 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved