×
Namespaces

Variants
Actions
Revision as of 17:35, 23 August 2013 by jasfox (Talk | contribs)

HERE Maps API - How to draw a rectangle

From Nokia Developer Wiki
Jump to: navigation, search

This article explains how to draw a rectangle on HERE Maps.

Article Metadata
Code Example
Source file: rectangle.html
Tested with
Devices(s): Internet Explorer, Google chrome, Firefox, Opera
Compatibility
Platform(s): Web browser
Dependencies: HERE Maps 2.2.4
Article
Keywords: HERE Maps, JavaScript, shapes, rectangle
Created: Maveric (21 Jun 2011)
Updated: avnee.nathani (31 Dec 2011)
Last edited: jasfox (23 Aug 2013)

Contents

Prerequisites

HERE 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 Terms and Conditions and check the Pricing Plans 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 for free following the instructions here

Implementation

API Definition of Rectangle:

    new nokia.maps.map.Rectangle (bounds, props)

Definition for the BoundingBox, used to form the rectangle:

new nokia.maps.geo.BoundingBox (topLeft, [bottomRight, [skipValidation]])

Example code

The following code will add a rectangle to the map:

function addRectangleToMap(map){
var boundingBox = new nokia.maps.geo.BoundingBox
([53.1, 13.1], [43.1, 40.1]);
map.objects.add(
new nokia.maps.map.Rectangle(boundingBox, {
precision: 36,
simplify: 16,
fillColor: "FFFFCC",
color: "E8FA75",
width: 8
})
);
}

NokiaMapsRectangleReal.png

A working example which displays a rectangle can be found at:

http://rawgithub.com/heremaps/examples/master/maps_js/rectangle.html

For more on the HERE Maps API

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

You may also access the interactive API explorer

407 page views in the last 30 days.
×