Class DetourEditor

DetourEditor

The DetourEditor is responsible for creating and editing detours

To construct a new DetourEditor, you need to provide an OpenLayers map instance:

const detourEditor = new sww.DetourEditor({
map: map
});

This will allow the user to create two types of lines:

  • closed_way_line: The closed way line
  • detour_line: The detour line

To edit an existing detour, you can provide the uuid of the detour:

const detourEditor = new sww.DetourEditor({
map: map,
uuid: "1234-5678-91011"
});

When the detour is loaded, a detour-loaded event is fired. To listen to this event, you can use the following code:

detourEditor.addEventListener("detour-loaded", () => {
console.log("Detour loaded");
});

To save the detour to the server, call the DetourEditor.save function:

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:

detourEditor.updateDetourProperties({
title: {"fr": "title fr", "de": "title de", "it": "title it", "en": "title en"},
url: "https://www.suisse-rando.ch",
});

Hierarchy

  • EventTarget
    • DetourEditor

Constructors

  • Parameters

    • options: DetourEditorOptions

    Returns DetourEditor

Accessors

  • get detourLineType(): "closed_way_line" | "detour_line"
  • Returns "closed_way_line" | "detour_line"

  • set detourLineType(value): void
  • Parameters

    • value: "closed_way_line" | "detour_line"

    Returns void

  • get edit(): boolean
  • Returns boolean

  • set edit(value): void
  • Parameters

    • value: boolean

    Returns void

  • get snapping(): boolean
  • Returns boolean

  • set snapping(value): void
  • Parameters

    • value: boolean

    Returns void

Methods

  • Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

    The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

    When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

    When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in ยง 2.8 Observing event listeners.

    When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

    If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

    The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optionaloptions: boolean | AddEventListenerOptions

    Returns void

  • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • Returns the uuid of the detour. If the detour is not saved yet, this function returns undefined.

    Returns undefined | string

  • Redo the last action

    Returns void

  • Removes the event listener in target's event listener list with the same type, callback, and options.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optionaloptions: boolean | EventListenerOptions

    Returns void

  • Create or update the detour to the server

    Returns Promise<string>

  • Undo the last action

    Returns void

  • Update the detour properties

    Parameters

    • properties: Record<string, unknown>

    Returns void