×
Namespaces

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

HERE Maps API - How to check the Date Border Crossing

From Nokia Developer Wiki
Jump to: navigation, search

This article explains how to check the Date Border Crossing using the HERE Maps API.

Article Metadata
Code ExampleTested with
Devices(s): FireFox, Internet Explorer, Google Chrome, Opera
Compatibility
Platform(s): Web
Dependencies: HERE Maps API 2.2.4
Article
Keywords: HERE Maps, JavaScript, Date Border
Created: Maveric (16 Nov 2011)
Last edited: jasfox (23 Aug 2013)

Contents

Introduction

The isCDB flag of the BoundingBox in HERE Maps API has been added since v2 to indicate that the bounding box is crossing the date border. A bounding box which is spanned from -180° (left) to +180° (right) is NOT crossing the date border. Default value is false.

The API reference link: http://developer.here.net/docs/maps_js/topics_api_pub/nokia.maps.geo.BoundingBox.html#topic-apiref__BoundingBox-isCDB

The International Date Line (IDL) Definition by Wikipedia.org

IDL is a generally north-south imaginary line on the surface of the Earth, passing through the middle of the Pacific Ocean, that designates the place where each calendar day begins. It is roughly along 180° longitude, opposite the Prime Meridian, but it is drawn with diversions to pass around some territories and island groups.Crossing the IDL traveling east results in a day or 24 hours being subtracted, so that the traveler repeats the date to the west of the line. Full description here: http://en.wikipedia.org/wiki/International_Date_Line

Example code

This example first adds two Markers for which the BoundingBox is not crossing the International Date Line. A third Marker is then added by clicking on the map which will also check to see if the BoundingBox to have crossed the IDL.

function setUpContainer(){
this.container = new nokia.maps.map.Container();
container.objects.addAll([
new nokia.maps.map.StandardMarker([-18.10, 176.46]),
new nokia.maps.map.StandardMarker([-18.10, 180.00])]
);
 
map.objects.add(container);
map.zoomTo(container.getBoundingBox(),false,true);
}
function addOnClickEventListener(map){
map.addListener("click", function(evt){
evt.preventDefault();
coordinate = map.pixelToGeo(evt.displayX, evt.displayY);
container.objects.add(new nokia.maps.map.Marker(coordinate));
checkDateBorder(container);});
}
function checkDateBorder(container){
if (container.getBoundingBox().isCDB){
$("#dateline").text("True - The Bounding box crosses the date border");
} else {
$("#dateline").text("False - The Bounding box is not crossing the date border");
}
}

A working example can be found at:

http://rawgithub.com/heremaps/examples/master/maps_js/international-date-line-check.html

For more on HERE Maps API

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

You may also access the interactive API explorer

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

×