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

    Maplibre GL Terra Draw Measure Control

    Hierarchy (View Summary)

    Index
    _cssPrefix: string = ''
    _fontGlyphs?: string[]
    _isExpanded: boolean = false
    controlContainer?: HTMLElement
    defaultMode: string = 'render'
    events: { [key: string]: [(event: EventArgs) => void] } = {}
    map?: Map$1
    modeButtons: { [key: string]: HTMLButtonElement } = {}
    terradraw?: TerraDraw
    • get cssPrefix(): string

      CSS prefix for the control buttons. Default is empty string

      Returns string

    • get distanceIsochroneCostingModel(): "auto" | "pedestrian" | "bicycle"

      Get the means of transport for Valhalla distance isochrone api

      Returns "auto" | "pedestrian" | "bicycle"

      isochroneCostingModelType

      'pedestrian', 'bicycle', 'auto'
      
    • set distanceIsochroneCostingModel(
          value: "auto" | "pedestrian" | "bicycle",
      ): void

      Set the means of transport for Valhalla distance isochrone api

      Parameters

      • value: "auto" | "pedestrian" | "bicycle"

        isochroneCostingModelType

      Returns void

      'pedestrian', 'bicycle', 'auto'
      
    • get fontGlyphs(): string[]

      Get/Set font glyph for valhalla 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 MaplibreValhallaControl()
      drawControl.fontGlyphs = ['Open Sans Italic']
      map.addControl(drawControl)

      Returns string[]

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

      Get/Set font glyph for the TextMode label layer ({prefix}-text-labels).

      As default, the TextMode label uses sans-serif so it is not constrained by the glyphs available in your maplibre style. See https://maplibre.org/maplibre-style-spec/layers/#text-font

      If you are using your own maplibre style or a different map provider, you probably need to set the font glyphs to match glyphs available in 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 MaplibreTerradrawControl({ modes: ['text'] })
      drawControl.fontGlyphs = ['Open Sans Italic']
      map.addControl(drawControl)

      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

    • get routingCostingModel(): "auto" | "pedestrian" | "bicycle"

      Get the means of transport for Valhalla routing api

      Returns "auto" | "pedestrian" | "bicycle"

      costingModelType

      'pedestrian', 'bicycle', 'auto'
      
    • set routingCostingModel(value: "auto" | "pedestrian" | "bicycle"): void

      Set the means of transport for Valhalla routing api

      Parameters

      • value: "auto" | "pedestrian" | "bicycle"

        costingModelType

      Returns void

      'pedestrian', 'bicycle', 'auto'
      
    • get routingDistanceUnit(): "kilometers" | "miles"

      Get the distance unit for Valhalla routing api

      Returns "kilometers" | "miles"

      routingDistanceUnitType

      'kilometers', 'miles'
      
    • set routingDistanceUnit(value: "kilometers" | "miles"): void

      Set the distance unit for Valhalla routing api

      Parameters

      • value: "kilometers" | "miles"

        routingDistanceUnitType

      Returns void

      'kilometers', 'miles'
      
    • get showDeleteConfirmation(): boolean

      Show delete confirmation popup when deleting features if true. Default is false

      Returns boolean

    • set showDeleteConfirmation(value: boolean): void

      Set show delete confirmation popup when deleting features if true. Default is false

      Parameters

      • value: boolean

      Returns void

    • get timeIsochroneCostingModel(): "auto" | "pedestrian" | "bicycle"

      Get the means of transport for Valhalla time isochrone api

      Returns "auto" | "pedestrian" | "bicycle"

      isochroneCostingModelType

      'pedestrian', 'bicycle', 'auto'
      
    • set timeIsochroneCostingModel(value: "auto" | "pedestrian" | "bicycle"): void

      Set the means of transport for Valhalla time isochrone api

      Parameters

      • value: "auto" | "pedestrian" | "bicycle"

        isochroneCostingModelType

      Returns void

      'pedestrian', 'bicycle', 'auto'
      
    • Apply the given font glyphs to the provided symbol layer specs and, when they already exist on the map, to their live layers via setLayoutProperty.

      Shared by subclasses (e.g. MaplibreMeasureControl, MaplibreValhallaControl) so their fontGlyphs setters can reuse the same layer-update logic.

      Parameters

      • fontNames: string[]

        font glyph names to apply as text-font

      • layers: (SymbolLayerSpecification | undefined)[]

        symbol layer specs to update (undefined entries are skipped)

      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

    • Clear GeoJSON feature related to extended control such as measure and valhalla by TerraDraw feature ID

      Parameters

      • sourceIds: string[]

        the array of source ID to delete

      • ids: FeatureId[] | undefined = undefined

        the array of feature ID. Optional, if undefined, delete all labels for source

      Returns void

      void

    • Create (or refresh) the MapLibre GL symbol layer used to render committed text labels from TerraDrawTextMode.

      Called automatically by onAdd when the text mode is active, and again after every TerraDraw finish event so newly committed labels appear immediately.

      1. Reads all committed text features from the TerraDraw snapshot (features where properties.mode === 'text' and properties.text is non-empty).
      2. If the {prefix}-text GeoJSON source already exists, calls setData to update it in place (no layer teardown/rebuild).
      3. If the source does not yet exist, adds the source and a {prefix}-text-labels symbol layer with defaults for text-field, text-size, text-font, text-color, and text-halo-*.
      4. Calls map.moveLayer('{prefix}-text-labels') to ensure the symbol layer renders above all other TerraDraw layers.

      The {prefix} comes from adapterOptions.prefixId (default 'td'), so with the default prefix the layer id is td-text-labels.

      Parameters

      • map: Map$1

        The MapLibre GL Map instance.

      • Optionalstyles: TextModeStyling

        Optional style overrides forwarded to the MapLibre symbol layer.

      Returns void

    • get GeoJSON features

      Parameters

      • onlySelected: boolean = false

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

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

      FeatureCollection in GeoJSON format

    • Delete selected features from the store.

      Valhalla result features created from the same operation share properties.groupId (isochrone contour polygons of one request, or a route line and its node points). The selection is expanded to the whole group so that e.g. deleting one contour polygon removes its siblings, and deleting a route line removes its node points as well.

      Returns void

    • Restore the default paint properties on the {prefix}-text-labels layer after a text feature is deselected.

      Resets text-color, text-halo-color, and text-halo-width from TextModeStyling defaults. Also refreshes the GeoJSON source to clear the TerraDraw selected flag from the feature data.

      Called automatically on terradraw.on('deselect').

      Returns void

    • Apply highlighted styles to the {prefix}-text-labels layer when a text feature is selected via TerraDrawSelectMode.

      Refreshes the GeoJSON source so the TerraDraw selected property is current, then sets data-driven text-size and text-halo-color expressions that make the selected label slightly larger and give it a white halo. If the selected feature is not a text feature, delegates to resetTextLabelLayer instead.

      Called automatically on terradraw.on('select').

      Parameters

      • featureId: FeatureId

        The TerraDraw feature ID that was selected.

      Returns void

    • Show delete confirmation dialog.

      Parameters

      • onConfirm: () => void

        Callback function that will be invoked when the user confirms deletion by clicking the "Delete" button in the dialog; typically used to delete all features before the dialog is closed.

      • title: string = 'Delete All Features'

        Optional dialog title. Defaults to 'Delete All Features'.

      • message: string = 'Are you sure you want to delete all features?'

        Optional dialog message. Defaults to 'Are you sure you want to delete all features?'.

      Returns void