sww
    Preparing search index...

    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
    Index

    Constructors

    • Parameters

      • options: DetourEditorOptions

      Returns DetourEditor

    Accessors

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

      Returns "closed_way_line" | "detour_line"

    • set detourLineType(value: "closed_way_line" | "detour_line"): void

      Parameters

      • value: "closed_way_line" | "detour_line"

      Returns void

    • get edit(): boolean

      Returns boolean

    • set edit(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get snapping(): boolean

      Returns boolean

    • set snapping(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    Methods

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

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

      Returns void

    • Computes the properties (statistics) of a detour, including total time, distance, ascent and descent.

      Returns DetourProperties

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

      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

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

      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