(Difference between revisions)

HERE Maps API - How to draw a polygon

From Nokia Developer Wiki
Jump to: navigation, search
Maveric (Talk | contribs)
m (Maveric - - Example code)
hamishwillee (Talk | contribs)
m (Hamishwillee - Add Ovi Maps category)
Line 1: Line 1:
[[Category:Web]][[Category:Browser]][[Category:Ovi Maps]]

Revision as of 03:38, 12 October 2011



In this article we will see how to draw a polygon on Ovi Maps.


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

Important about Maps credentials

With Ovi Maps API you can start without having any credentials given, but you might face a performance gap. In order to get the full potential out of the offering, you must get the credentials that authenticate your application against the Services. Please read through the Location API.

For more information on how to obtain the credentials, please start with the Ovi Maps API Developers Guide section "Acquiring API credentials"


The API definition:

    new ovi.mapsapi.map.Polygon (path, props) 
ovi.mapsapi.geo.Strip | ovi.mapsapi.geo.Coordinate[]} path The path as coordinate strip.
ovi.mapsapi.map.Polygon.Properties} props The initial values of the specified properties.

To draw the Polygon we will create a new geo Strip with Coordinates and then a new Polygon will be instantiated using it. The Properties are defined the same way for drawing a Circle, Polyline or a Polygon.

Example code

<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" charset="utf-8">
<link rel="stylesheet" href="style.css" />
<div id="map" style="width:100%; height:80%;"></div>
<script type="text/javascript">
myGeoStrip = new ovi.mapsapi.geo.Strip([52,13,100,48,2,100,48,16,100,52,13,100], "values lat lng alt");
var map = new ovi.mapsapi.map.Display(document.getElementById("map"), // new instance of Ovi Maps
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': 4,
'center':[53.1, 13.1]
map.set("baseMapType", map.SATELLITE);
//new ovi.mapsapi.map.Polygon (path, props)
{ovi.mapsapi.geo.Strip | ovi.mapsapi.geo.Coordinate[]} path The path as coordinate strip.
{ovi.mapsapi.map.Polygon.Properties} props The initial values of the specified properties.

new ovi.mapsapi.map.Polygon(myGeoStrip,
precision: 36,
simplify: 16,
fillColor: "FFFFCC",
color: "E8FA75",
width: 8

For more on Ovi Maps API

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


Tested with

Google Chrome 11.0x

Mozilla Firefox 5.0b

232 page views in the last 30 days.