3.5 KiB
Events
Subscribe to events using the on(eventName, function)
method. Example:
let client = new FacilMap.Client("https://facilmap.org/", "testPad");
client.on("padData", (padData) => {
document.title = padData.name;
});
connect
, disconnect
, connect_error
, error
, reconnect
, reconnect_attempt
, reconnect_error
, reconnect_failed
These events come from socket.io and are documented there under the section “Events”.
padData
The settings of the map have changed or are retrieved for the first time.
Note that when this event is fired, the read-only and/or the read-write ID of the map might have changed. The padId
property is updated automatically.
Type: padData
deletePad
The map has been deleted.
marker
An existing marker is retrieved for the first time, has been modified, or a new marker has been created in the current bbox.
Type: marker
deleteMarker
A marker has been removed. This event is emitted for all markers in the map, even if they are outside of the current bbox (in case that a marker outside of the current bbox is cached).
Type: {id: "<markerId>"}
line
An existing line is retrieved for the first time, has been modified, or a new line has been created. Note that line
objects only contain the line metadata, not its track points (those are handled separately as linePoints
). This is why
all line objects of the map are sent to the client, regardless of the current bbox.
Type: line without trackPoints
deleteLine
A line has been removed.
Type: {id: "<lineId>"}
linePoints
New track points for an existing line are retrieved after a change of bbox (reset == false
), or the line has been
modified, so the new track points are retrieved (reset == true
).
Type: {
- id (number): The ID of the line that these track points belong to
- reset (boolean): Whether to remove all cached track points for this line (
true
) or to merge these track points with the cached ones (false
). - trackPoints (Array<trackPoint>): The track points
}
view
A view is retrieved for the first time, has been modified, or a new view has been created.
Type: view
deleteView
A view has been removed.
Type: {id: "<viewId>"}
type
A type is retrieved for the first time, has been modified, or a new type has been created.
Type: type
deleteType
A type has been removed.
Type: {id: "<typeId>"}
history
An entry of the modification history is retrieved for the first time, or a new entry has been created due to something
being modified. Note that this event is only fired when the client has subscribed using listenToHistory()
.
Type: historyEntry
routePoints
New track points for the temporary route are retrieved after a change of bbox.
Type: Array<trackPoint>
loadStart
, loadEnd
This event is fired every time some request is sent to the server and when the response has arrived. It can be used to display a loading indicator to the user. Note that multiple things can be loading at the same time. Example code:
let loading = 0;
client.on("loadStart", () => {
++loading;
showLoadingIndicator();
});
client.on("loadEnd", () => {
if(--loading == 0)
hideLoadingIndicator();
});