Class TerraDraw

Hierarchy

  • TerraDraw

Constructors

  • Parameters

    • options: {
          adapter: TerraDrawAdapter;
          modes: TerraDrawBaseDrawMode<any>[];
      }
      • adapter: TerraDrawAdapter
      • modes: TerraDrawBaseDrawMode<any>[]

    Returns TerraDraw

Properties

_adapter: TerraDrawAdapter
_enabled: boolean = false
_eventListeners: {
    change: ChangeListener[];
    deselect: DeselectListener[];
    finish: FinishListener[];
    select: SelectListener[];
}

Type declaration

  • change: ChangeListener[]
  • deselect: DeselectListener[]
  • finish: FinishListener[]
  • select: SelectListener[]
_instanceSelectMode: undefined | string
_mode: TerraDrawBaseDrawMode<any>
_modes: {
    [mode: string]: TerraDrawBaseDrawMode<any>;
}

Type declaration

  • [mode: string]: TerraDrawBaseDrawMode<any>
_store: GeoJSONStore

Accessors

  • get enabled(): boolean
  • Alpha

    A property used to determine whether the instance is active or not. You can use the start method to set this to true, and stop method to set this to false. This is a read only property.

    Returns boolean

    true or false depending on if the instance is stopped or started

Methods

  • Alpha

    A method for adding features to the store. This method will validate the features. Features must match one of the modes enabled in the instance.

    Parameters

    Returns void

  • Alpha

    Removes all data from the current store and removes any rendered layers via the registering the adapter.

    Returns void

  • Parameters

    • __namedParameters: {
          lat: number;
          lng: number;
      }
      • lat: number
      • lng: number
    • Optional options: {
          ignoreSelectFeatures: boolean;
          pointerDistance: number;
      }
      • ignoreSelectFeatures: boolean
      • pointerDistance: number

    Returns GeoJSONStoreFeatures[]

  • Alpha

    Gets the features at a given longitude and latitude. Will return point and linestrings that are a given pixel distance away from the lng/lat and any polygons which contain it.

    Parameters

    • lngLat: {
          lat: number;
          lng: number;
      }
      • lat: number
      • lng: number
    • Optional options: {
          ignoreSelectFeatures: boolean;
          pointerDistance: number;
      }
      • ignoreSelectFeatures: boolean
      • pointerDistance: number

    Returns GeoJSONStoreFeatures[]

  • Alpha

    Takes a given pointer event and Will return point and linestrings that are a given pixel distance away from the lng/lat and any polygons which contain it.

    Parameters

    • event: PointerEvent | MouseEvent
    • Optional options: {
          ignoreSelectFeatures: boolean;
          pointerDistance: number;
      }
      • ignoreSelectFeatures: boolean
      • pointerDistance: number

    Returns GeoJSONStoreFeatures[]

  • Alpha

    A method for getting the current mode name

    Returns string

    the current mode name

  • Alpha

    Unregisters a Terra Draw event

    Type Parameters

    • T extends keyof TerraDrawEventListeners

    Parameters

    • event: keyof TerraDrawEventListeners

      The name of the event you wish to unregister

    • callback: TerraDrawEventListeners[T]

      The callback you originally provided to the 'on' method

    Returns void

  • Alpha

    Registers a Terra Draw event

    Type Parameters

    • T extends keyof TerraDrawEventListeners

    Parameters

    • event: T

      The name of the event you wish to listen for

    • callback: TerraDrawEventListeners[T]

      The callback with you wish to be called when this event occurs

    Returns void

  • Alpha

    A method for removing features to the store

    Parameters

    • ids: string[]

    Returns void

  • Alpha

    A method for setting the current mode by name. Under the hood this will stop the previous mode and start the new one.

    Parameters

    • mode: string

      The mode name you wish to start

    Returns void

  • Alpha

    Allows the setting of a style for a given mode

    Type Parameters

    • Styling extends Record<string, number | `#${string}`>

    Parameters

    • mode: string

      The mode you wish to set a style for

    • styles: Styling

      The styles you wish to set for the mode - this is the same as the initialisation style schema

    Returns void

  • Alpha

    A method starting Terra Draw. It put the instance into a started state, and in registers the passed adapter giving it all the callbacks required to operate.

    Returns void

  • Alpha

    A method for stopping Terra Draw. Will clear the store, deregister the adapter and remove any rendered layers in the process.

    Returns void

Generated using TypeDoc