@watergis/maplibre-gl-terradraw
    Preparing search index...

    Maplibre GL Terra Draw Measure Control

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _isExpanded: boolean = false
    controlContainer?: HTMLElement
    defaultMode: string = 'render'
    events: { [key: string]: [(event: EventArgs) => void] } = {}
    map?: Map$1
    modeButtons: { [key: string]: HTMLButtonElement } = {}
    options: TerradrawControlOptions = defaultControlOptions
    terradraw?: TerraDraw

    Accessors

    • get fontGlyphs(): string[]

      Get/Set font glyph for measure control layers

      As default, this maesure control uses maplibre's default font glyphs(Open Sans Regular,Arial Unicode MS Regular) described at https://maplibre.org/maplibre-style-spec/layers/#text-font

      If you are using your own maplibre style or different map privider, you probably need to set the font glyphs to match your maplibre style.

      Font glyph availability depends on what types of glyphs are supported by your maplibre style (e.g., Carto, Openmap tiles, Protomap, Maptiler, etc.) Please make sure the font glyphs are available in your maplibre style.

      Usage:

      const drawControl = new MaplibreMeasureControl()
      drawControl.fontGlyphs = ['Open Sans Italic']
      map.addControl(drawControl)

      Returns string[]

    • set fontGlyphs(fontNames: string[]): void

      Parameters

      • fontNames: string[]

      Returns void

    • get isExpanded(): boolean

      get the state of whether the control is expanded or collapsed

      Returns boolean

    • set isExpanded(value: boolean): void

      set the state of the control either expanded or collapsed. terradraw mode will be reset if the state is changed. either expanded or collapsed event is dispatched when changed

      Parameters

      • value: boolean

      Returns void

    Methods

    • Add Terra Draw drawing mode button

      Parameters

      • mode:
            | "render"
            | "point"
            | "linestring"
            | "polygon"
            | "rectangle"
            | "circle"
            | "freehand"
            | "angled-rectangle"
            | "sensor"
            | "sector"
            | "select"
            | "delete-selection"
            | "delete"
            | "download"

        Terra Draw mode name

      Returns void

    • clean maplibre style to filter only for terradraw related layers or without them. If options are not set, returns original style given to the function.

      This can be useful incase users only want to get terradraw related layers or without it.

      Usage: cleanStyle(map.getStyle, { excludeTerraDrawLayers: true}) cleanStyle(map.getStyle, { onlyTerraDrawLayers: true})

      Parameters

      • style: StyleSpecification

        maplibre style spec

      • Optionaloptions: { excludeTerraDrawLayers?: boolean; onlyTerraDrawLayers?: boolean }
        • OptionalexcludeTerraDrawLayers?: boolean

          return maplibre style without terradraw layers and sources

        • OptionalonlyTerraDrawLayers?: boolean

          return maplibre style with only terradraw layers and sources

      Returns StyleSpecification

    • get GeoJSON features

      Parameters

      • onlySelected: boolean = false

        If true, returns only selected features. Default is false.

      Returns undefined | { features: GeoJSONStoreFeatures[]; type: string }

      FeatureCollection in GeoJSON format

    • Recalculate area and distance in TerraDraw snapshot

      if you use addFeatures to restore GeoJSON features to TerraDraw, this recalc method needs to be called to re-measure again.

      For example, the below code is an example usage.

      drawInstance?.addFeatures(initData);
      map?.once('idle', ()=>{
      drawControl.recalc()
      })

      Returns void