Livemap
This class represents an Embed of a Livemap and allows the developper to interact with it.
Kind: global class
- Livemap
- new Livemap(container, options, iframeEmbed)
- .centerTo
.findNearestPinpoint- .findNearestPinpoints
- .aroundMe
- .stopNavigation
- .getCenter
- .getZoom
- .setCenter
- .setFilters
- .setZoom
- .setBearing
.removeUserLocationMarker.setUserLocation- .getUserLocation
.setUserPose.setUserAttitude- .getUserHeading
- .openPinpoint
- .closePinpoint
- .openEvent
- .closeEvent
- .openList
- .closeList
- .closePopin
- .addEventListener
- .removeEventListener
- .setPinpoints
- .setEvents
- .fitBounds
- .waitForReady
- .animateMarker(ppid, animation, duration)
- .navigateFromPinpointToPinpoint(startPinpoint, endPinpoint)
- .navigateToPinpoint(ppid, [startLocation], [initialHeading])
new Livemap(container, options, iframeEmbed)
This class is used to create a new livemap
When you do wemap.v1.createLivemap(container, options, useIframe)
, this is the class used behind,
then you are allowed to use this class to interact with the livemap
Param | Type | Default | Description |
---|---|---|---|
container |
| Container of the livemap | |
options |
| Options of the Livemap (emmid & token entries are mandatory) | |
iframeEmbed |
|
| Set to false if you want the livemap in the dom |
livemap.centerTo
Center the map on the given position and set the zoom level.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
center |
| New center |
center.latitude |
| New center latitude |
center.longitude |
| New center longitude |
zoom |
| New zoom level |
animate |
| Whether to animate the map movement |
Example
var center = { latitude: 43.609395, longitude: 3.884215 };var zoom = 13;livemap.centerTo(center, zoom);
livemap.findNearestPinpoint
Deprecated
Kind: instance property of Livemap
Returns: - a promise that resolves with the nearest pinpoint
Param | Type | Description |
---|---|---|
options |
| Options for the search, for now only 'center'. |
livemap.findNearestPinpoints
Find the nearest pinpoints from a point.
Kind: instance property of Livemap
Returns: - a promise that resolves with the nearest pinpoints.
Param | Type | Description |
---|---|---|
options |
| Options for the search. Available options are: center. |
options.center |
| center for the search. |
options.center.latitude |
| center latitude for the search. |
options.center.longitude |
| center longitude for the search. |
Example
var center = { latitude: 43.609395, longitude: 3.884215 };livemap.findNearestPinpoints({ center: center }).then(function(pinpoints) {// do something});
livemap.aroundMe
Center the map on the user's location.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Example
livemap.aroundMe();
livemap.stopNavigation
Stop the currently running navigation.
Kind: instance property of Livemap
Returns: - a promise that resolves if no error occurs.
Example
livemap.stopNavigation();
livemap.getCenter
Return the map's geographical center.
Kind: instance property of Livemap
Returns: - a promise that resolves with the map center.
Example
livemap.getCenter().then(function(center) {// Do something with center});
livemap.getZoom
Return the map's zoom level.
Kind: instance property of Livemap
Returns: - a promise that resolves with the current zoom level.
Example
livemap.getZoom().then(function(zoom) {// Do something with zoom});
livemap.setCenter
Set the map's geographical center.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
center |
| New center |
center.latitude |
| New center latitude |
center.longitude |
| New center longitude |
Example
var center = { latitude: 43.609395, longitude: 3.884215 };livemap.setCenter(center);
livemap.setFilters
Update search filters (dates, tags, text).
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
filters |
| Filters to apply to the search |
filters.startDate |
| Start date at YYYY-MM-DD format |
filters.endDate |
| End date at YYYY-MM-DD format |
filters.query |
| text query |
filters.tags |
| array of string tags |
Example
var filters = {startDate: '2017-02-01',endDate: '2017-02-05',query: 'arts décoratifs',tags: ['monument-historique', 'musee-de-france']};livemap.setFilters(filters);
livemap.setZoom
Set the map's zoom level.
Kind: instance property of Livemap
Returns: - a promise which resolves when the action has been sent to the Livemap.
Param | Type | Description |
---|---|---|
zoom |
| New zoom |
Example
var zoom = 8;livemap.setZoom(zoom);
livemap.setBearing
Set the map's bearing.
Kind: instance property of Livemap
Returns: - a promise which resolves when the action has been sent to the Livemap.
Param | Type | Default | Description |
---|---|---|---|
bearing |
| New bearing (in degrees) | |
[options] |
|
| Options available |
options.duration |
| Duration of animation in ms |
Example
var bearing = 90;livemap.setBearing(bearing);
Example
var bearing = 10;var options = {duration: 1000};livemap.setBearing(bearing, options);
livemap.removeUserLocationMarker
Deprecated
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
livemap.setUserLocation
Deprecated
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
coordinates |
| User location |
livemap.getUserLocation
Get the user location. The promise resolve with null if the livemap is not listening on user position. If you want locate the user use aroundMe instead
Kind: instance property of Livemap
Returns: - a promise which resolves with the user location is no error occured.
See: aroundMe
Example
livemap.getUserLocation().then(function(location) {// Do something with location});
livemap.setUserPose
Deprecated
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
pose |
| Device position and attitude |
livemap.setUserAttitude
Deprecated
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
pose |
| Device position and attitude |
livemap.getUserHeading
Get the user heading. The promise resolve with null if the livemap is not listening on user heading.
Kind: instance property of Livemap
Returns: - a promise which resolves with the user heading if no error occured.
Example
livemap.getUserHeading().then(function(heading) {// Do something with heading});
livemap.openPinpoint
Open a pinpoint on the map.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
pid |
| Pinpoint ID |
Example
var pid = 1234;livemap.openPinpoint(pid);
livemap.closePinpoint
Close the current opened pinpoint. Go to the search view.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Example
livemap.closePinpoint();
livemap.openEvent
Open an event on the map. This can only be used for maps which use events.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
eid |
| Event ID |
Example
var eid = 1234;livemap.openEvent(eid);
livemap.closeEvent
Close the current opened event. Go to the search view.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Example
livemap.closeEvent();
livemap.openList
Open a list on the map.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
lid |
| List ID |
Example
var lid = 1234;livemap.openList(lid);
livemap.closeList
Close the current opened list. Go to the search view.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Example
livemap.closeList();
livemap.closePopin
Close the current opened popin
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Example
livemap.closePopin();
livemap.addEventListener
Register a listener for a specific event type.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
eventName |
| Name of event |
callback |
| Callback to receive the events |
Example
livemap.addEventListener('pinpointOpen', function(pinpoint) {// Do something with pinpoint});
Example
livemap.addEventListener('contentUpdated', function(data) {// Do something with data});
livemap.removeEventListener
Remove the given listener for a specific event type.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
eventName |
| Name of event |
callback |
| Callback to remove |
Example
var myCallback = function(pinpoint) {// Do something};// Add listenerlivemap.addEventListener('contentUpdated', myCallback);// Remove listenerlivemap.removeEventListener('contentUpdated', myCallback);
livemap.setPinpoints
Populates the map with given pinpoints.
Kind: instance property of Livemap
Returns: - a promise which resolves if no exception is raised.
The resolved object contains the bounds property that encompasses all the points given as input.
Facilitates the use of the fitBounds method.
Param | Type | Description |
---|---|---|
pinpoints | Array.<Pinpoint> | Pinpoints to populate the map. |
Example
var container = document.getElementById('wemap-container');var options = {emmid: 7087,token: 'at5819f0d0844cd5.60578643'};var livemap = wemap.v1.createLivemap(container, options);var pinpoints = [{id: 1,name: 'Wemap Office',latitude: 43.609138,longitude: 3.884193,description: 'Where magic happens'},{id: 2,name: 'Effeil Tower',latitude: 48.858370,longitude: 2.294481,description: 'What is that ?',media_url: 'http://1.bp.blogspot.com/_2IU2Nt4rD1k/S7NYdiVpUeI/AAAAAAAABRY/YWJbdCPlllI/s400/Eiffel_Tower.JPG',media_type: 'image'}];livemap.setPinpoints(pinpoints).then(function() {// now you can open one of the created pinpointslivemap.openPinpoint(2);});
livemap.setEvents
Populates the map with given events.
Kind: instance property of Livemap
Returns: - a promise which resolves if no exception is raised.
The resolved object contains the bounds property that encompasses all the pinpoints of the events given as input.
Facilitates the use of the fitBounds method.
Param | Type | Description |
---|---|---|
events | Array.<Event> | Events to populate the map. |
events[].id |
| Integer representing the id of the event. |
events[].name |
| Name of the event. |
events[].description |
| Description of the event. |
events[].pinpoint |
| Pinpoint related to the event. Check setPinpoints method for pinpoint fields. |
events[].dates | Array.<Object> | Dates of the events. Each item must have start and end entries which must be ISO string dates. |
Example
const container = document.getElementById('wemap-container');const options = {emmid: 7087,token: 'at5819f0d0844cd5.60578643'};const livemap = wemap.v1.createLivemap(container, options);const pinpoint = {id: 1,name: 'Wemap Office',latitude: 43.609138,longitude: 3.884193,description: 'Where magic happens'};const events = [{id: 1,name: 'First event',pinpoint: pinpoint,description: 'The description of my great event',dates: [{start: '2018-09-15T08:00:00.000Z',end: '2018-09-16T08:00:00.000Z'}]}];livemap.setEvents(events).then(() => {// now you can open one of the created eventslivemap.openEvent(1);});
livemap.fitBounds
Fit the map on given bounds.
Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.
Param | Type | Description |
---|---|---|
bounds |
| [W,S,E,N] Coordinates bounds to fit on. |
options |
| Options for the action. Available options are: padding. |
options.padding |
| {bottom, top, left, right} padding to add to bounds. |
options.animate |
| If animation should occur |
Example
var bounds = [2.294481, 43.609138, 3.884193, 48.85837];var options = {padding: {top: 65}};livemap.fitBounds(bounds, options);
livemap.waitForReady
Simply resolve when the Livemap is ready. Use this function to ensure that the livemap is ready before interacting with.
Kind: instance property of Livemap
Returns: - A promise which resolves when the Livemap is ready.
Example
livemap.waitForReady().then(function() {// You can safely interact with the livemap object});
livemap.animateMarker(ppid, animation, duration)
Animate a marker
Kind: instance method of Livemap
Returns: - a promise that resolves when animation is fired
Param | Type | Description |
---|---|---|
ppid |
| Id of pinpoint |
animation |
| name of animation, currently available (bounce |
duration |
| duration of animation in ms |
Example
var ppid = 1234;var animation = "bounce";var duration = 2000;livemap.animateMarker(ppid, animation, duration);
livemap.navigateFromPinpointToPinpoint(startPinpoint, endPinpoint)
Start the navigation between two given pinpoints.
Kind: instance method of Livemap
Param | Type | Description |
---|---|---|
startPinpoint |
| Pinpoint representing the start location. |
endPinpoint |
| Destination pinpoint |
Example
var startPinpoint = {id: 1234,latitude: 43.609395,longitude: 3.884215};var endPinpoint = {id: 1234,latitude: 43.6094,longitude: 3.884789};livemap.navigateFromPinpointToPinpoint(startPinpoint, endPinpoint);
livemap.navigateToPinpoint(ppid, [startLocation], [initialHeading])
Start navigation to a pinpoint. Can be an absolute navigation (start location based on phone sensors) or a relative navigation (given start location & heading). If start location and initialHeading are not provided, the navigation will start with the user location
Kind: instance method of Livemap
Returns: - a promise that resolves once the navigation is correctly started.
Param | Type | Default | Description |
---|---|---|---|
ppid |
| Id of the destination pinpoint. | |
[startLocation] |
|
| For relative navigation only. Navigation start location { lat, lng, alt }. |
[initialHeading] |
| For relative navigation only. Navigation start heading (in degrees). |
Example
var pinpointId = 1234;livemap.navigateToPinpoint(pinpointId)
Example
var pinpointId = 1234;var startLocation = { lat: 43.609395, lng: 3.884215 };var initialHeading = 190;livemap.navigateToPinpoint(pinpointId, startLocation, initialHeading)