The addEventListener()
method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
Optional
options: boolean | AddEventListenerOptionsComputes the properties (statistics) of a detour, including total time, distance, ascent and descent.
The dispatchEvent()
method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
Returns the uuid of the detour. If the detour is not saved yet, this function returns undefined.
Redo the last action
The removeEventListener()
method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
Optional
options: boolean | EventListenerOptionsCreate or update the detour to the server
Undo the last action
Update the detour properties
DetourEditor
Demos
Description
The DetourEditor is responsible for creating and editing detours
To construct a new DetourEditor, you need to provide an OpenLayers map instance:
This will allow the user to create two types of lines:
closed_way_line
: The closed way linedetour_line
: The detour lineTo edit an existing detour, you can provide the uuid of the detour:
When the detour is loaded, a
detour-loaded
event is fired. To listen to this event, you can use the following code:Create or update the detour to the server
To save the detour to the server, call the DetourEditor.save function:
Update the detour properties
To update the properties of the detour that are not related to the geometries (for example the title, description, or any other property), call the DetourEditor.updateDetourProperties function and pass an object with the properties to update: