Livemap

This class represents an Embed of a Livemap and allows the developper to interact with it.

Kind: global class

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

ParamTypeDefaultDescription
container
DOMElement
Container of the livemap
options
object
Options of the Livemap (emmid & token entries are mandatory)
iframeEmbed
boolean
true
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.

ParamTypeDescription
center
object
New center
center.latitude
number
New center latitude
center.longitude
number
New center longitude
zoom
integer
New zoom level
animate
boolean
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

ParamTypeDescription
options
object
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.

ParamTypeDescription
options
object
Options for the search. Available options are: center.
options.center
object
center for the search.
options.center.latitude
number
center latitude for the search.
options.center.longitude
number
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.

ParamTypeDescription
center
object
New center
center.latitude
number
New center latitude
center.longitude
number
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.

ParamTypeDescription
filters
Object
Filters to apply to the search
filters.startDate
string
Start date at YYYY-MM-DD format
filters.endDate
string
End date at YYYY-MM-DD format
filters.query
string
text query
filters.tags
Array
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.

ParamTypeDescription
zoom
integer
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.

ParamTypeDefaultDescription
bearing
integer
New bearing (in degrees)
[options]
Object
{duration: 500}
Options available
options.duration
boolean
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.

ParamTypeDescription
coordinates
object
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.

ParamTypeDescription
pose
object
Device position and attitude

livemap.setUserAttitude

Deprecated

Kind: instance property of Livemap
Returns: - a promise that resolves if no exception is raised.

ParamTypeDescription
pose
object
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.

ParamTypeDescription
pid
integer
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.

ParamTypeDescription
eid
integer
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.

ParamTypeDescription
lid
integer
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.

ParamTypeDescription
eventName
ready
|
mapUpdate
|
contentUpdated
|
pinpointClick
|
actionButtonClick
|
pinpointOpen
|
pinpointClose
|
eventOpen
|
eventClose
|
listOpen
|
listClose
|
livemapMoved
|
guidingStarted
|
guidingUpdated
|
guidingStopped
|
fullscreenEnter
|
fullscreenExit
Name of event
callback
function
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.

ParamTypeDescription
eventName
string
Name of event
callback
function
Callback to remove

Example

var myCallback = function(pinpoint) {
// Do something
};
// Add listener
livemap.addEventListener('contentUpdated', myCallback);
// Remove listener
livemap.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.

ParamTypeDescription
pinpointsArray.<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 pinpoints
livemap.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.

ParamTypeDescription
eventsArray.<Event>Events to populate the map.
events[].id
number
Integer representing the id of the event.
events[].name
string
Name of the event.
events[].description
string
Description of the event.
events[].pinpoint
Object
Pinpoint related to the event. Check setPinpoints method for pinpoint fields.
events[].datesArray.<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 events
livemap.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.

ParamTypeDescription
bounds
array
[W,S,E,N] Coordinates bounds to fit on.
options
object
Options for the action. Available options are: padding.
options.padding
object
{bottom, top, left, right} padding to add to bounds.
options.animate
boolean
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

ParamTypeDescription
ppid
number
Id of pinpoint
animation
string
name of animation, currently available (bounce
duration
number
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

ParamTypeDescription
startPinpoint
Pinpoint
Pinpoint representing the start location.
endPinpoint
Pinpoint
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.

ParamTypeDefaultDescription
ppid
number
Id of the destination pinpoint.
[startLocation]
object
{}
For relative navigation only. Navigation start location { lat, lng, alt }.
[initialHeading]
number
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)