-
Notifications
You must be signed in to change notification settings - Fork 48
jHERE 1.0 beta docs
Massimiliano Marcon edited this page Nov 22, 2015
·
8 revisions
Maps made easy
Creates an instance of jHERE. The "new" is not required.
-
element
Element
DOM element where the map will be shown -
options
Object
options for the map
//Create an app at https://developer.here.com/myapps
//to get your app_id and app_code
var map = jHERE(document.querySelector('#map'), {
app_id: 'your_app_id',
app_code: 'your_app_code'
zoom: 14,
center: {lat: 52.5, lng: 13.3,
enable: ['zoombar', 'scalebar', 'settings', 'behavior']
}});
-
Object
the instance of jHERE
Sets the center of the map
-
newCenter
Object
the new center of the map (lat, lng) -
animate
boolean
an optional flag to enable and disable animations when recentering
//Sets the new center with animation
map.center({lat: 52.1, lng: 13.23}, true)
//Sets the new center without animation
map.center({lat: 52.1, lng: 13.23}, false)
-
Object
the instance of jHERE for chainability
Sets the zoom level of the map
-
newZoomLevel
Number
the zoom level -
animate
boolean
an optional flag to enable and disable animations when chaging zoom level
//Sets the zoom to 13 with animation
map.zoom(13, true)
//Sets the zoom to 3 with animation
map.zoom(3, false)
-
Object
the instance of jHERE for chainability
Sets the type for the map. Determines what type of map tiles are used.
-
type
string
the map type (normal, satellite, terrain) -
layer
string
(map, traffic, transit, xbase, base, labels)
//Sets the map type to terrain
//uses the default map layer (roads, labels, etc.)
map.type('terrain')
//Sets the map type to normal map
//uses a very basic layer with no roads an no labels
map.type('normal', 'xbase')
-
Object
the instance of jHERE for chainability
Attaches event listeners to the map.
-
event
String
the event name. Supported events are: mousedown, touchstart, pointerdown, mouseup, touchend, pointerup, mousemove, touchmove, pointermove, mouseenter, touchenter, pointerenter, mouseleave, touchleave, pointerleave, touchcancel, pointercancel, dragstart. dragend, drag, tap (covers click and tap), dbltab (covers also dblclick), longpress -
callback
Function
invoked when a map event is triggered. The callback is passed the event object extended with ageo
property that contains latitude and longitude of the pointer triggering the event.
//Logs latitude and longitude of a tap event
map.on('tap', function(e){
console.log(e.geo);
});
-
Object
the instance of jHERE for chainability
Adds a new marker to the map
-
coord
Object
the coordinates where the marker will be added -
options
Object
options for the marker
//Creates a new simple marker
map.marker({lat: 52.1, lng: 13.23})
-
Object
the instance of jHERE for chainability
Removes all the markers from the map
map.nomarkers();
-
Object
the instance of jHERE for chainability
Adds an info bubble to the map at the given coordinates
-
coord
Object
the coordinates where the marker will be added -
options
Object
options for the info bubble
var options = {
content: 'foo',
onclose: function(){
//Called when the info bubble is closed
},
//Specifies that the current info bubble
//is the only one present on the map.
//Useful when only one info bubble should be
//open at any given time
only: true
}
map.bubble({lat: 52.5, lng: 13.3}, options);
-
Object
the instance of jHERE for chainability
Removes all the info bubbles from the map
map.nobubbles();
-
Object
the instance of jHERE for chainability
Returns a reference to the original map object
-
closure
Function
a callback function to which the original map and the H namespace is passed
map.originalMap(function(map, H){
//map is the instance of the H.Map object that represents the map
//H is the main namespace of the HERE Maps API
});
-
Object
the instance of jHERE for chainability