jHERE 1.0 beta docs - mmarcon/jhere GitHub Wiki
jHERE
Maps made easy
jHERE(element, options)
Creates an instance of jHERE. The "new" is not required.
Parameters
- element
Element
DOM element where the map will be shown - options
Object
options for the map
Examples
//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']
}});
Returns
Object
the instance of jHERE
JH.center(newCenter, animate)
Sets the center of the map
Parameters
- newCenter
Object
the new center of the map (lat, lng) - animate
boolean
an optional flag to enable and disable animations when recentering
Examples
//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)
Returns
Object
the instance of jHERE for chainability
JH.zoom(newZoomLevel, animate)
Sets the zoom level of the map
Parameters
- newZoomLevel
Number
the zoom level - animate
boolean
an optional flag to enable and disable animations when chaging zoom level
Examples
//Sets the zoom to 13 with animation
map.zoom(13, true)
//Sets the zoom to 3 with animation
map.zoom(3, false)
Returns
Object
the instance of jHERE for chainability
JH.type(type, layer)
Sets the type for the map. Determines what type of map tiles are used.
Parameters
- type
string
the map type (normal, satellite, terrain) - layer
string
(map, traffic, transit, xbase, base, labels)
Examples
//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')
Returns
Object
the instance of jHERE for chainability
JH.on(event, callback)
Attaches event listeners to the map.
Parameters
- 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.
Examples
//Logs latitude and longitude of a tap event
map.on('tap', function(e){
console.log(e.geo);
});
Returns
Object
the instance of jHERE for chainability
JH.marker(coord, options)
Adds a new marker to the map
Parameters
- coord
Object
the coordinates where the marker will be added - options
Object
options for the marker
Examples
//Creates a new simple marker
map.marker({lat: 52.1, lng: 13.23})
Returns
Object
the instance of jHERE for chainability
JH.nomarkers()
Removes all the markers from the map
Examples
map.nomarkers();
Returns
Object
the instance of jHERE for chainability
JH.bubble(coord, options)
Adds an info bubble to the map at the given coordinates
Parameters
- coord
Object
the coordinates where the marker will be added - options
Object
options for the info bubble
Examples
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);
Returns
Object
the instance of jHERE for chainability
JH.nobubbles()
Removes all the info bubbles from the map
Examples
map.nobubbles();
Returns
Object
the instance of jHERE for chainability
JH.originalMap(closure)
Returns a reference to the original map object
Parameters
- closure
Function
a callback function to which the original map and the H namespace is passed
Examples
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
});
Returns
Object
the instance of jHERE for chainability