HERE Maps API - How to draw a polygon
hamishwillee
(Talk | contribs) m (Hamishwillee - Add Ovi Maps category) |
hamishwillee
(Talk | contribs) m (Hamishwillee - Automated change of category from Ovi Maps to Nokia Maps) |
||
| Line 1: | Line 1: | ||
| − | [[Category:Web]][[Category:Browser]][[Category: | + | [[Category:Web]][[Category:Browser]][[Category:Nokia Maps]] |
==Introduction== | ==Introduction== | ||
Revision as of 02:01, 6 December 2011
Contents |
Introduction
In this article we will see how to draw a polygon on Ovi Maps.
Prerequisites
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"
Implementation
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
<html>
<head>
<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" charset="utf-8">
</script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="map" style="width:100%; height:80%;"></div>
</body>
<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.
*/
map.objects.add(
new ovi.mapsapi.map.Polygon(myGeoStrip,
{
precision: 36,
simplify: 16,
fillColor: "FFFFCC",
color: "E8FA75",
width: 8
}));
</script>
</body>
</html>
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

