Options
All
  • Public
  • Public/Protected
  • All
Menu

A utility class for MGRS grid overlay text.

You can use this to implement a UI component that shows MGRS location info. For example, show in which MGRS zone / square the map is zoomed in on.

The supported formats are the same as MGRSGridSetting.labelFormat. The format is ignored when using COMMON_MAP_COORDINATE.

Example usage:

  // create a default MGRS grid layer
  const mgrsGrid = createDefaultMGRSGrid();
  const mgrsGridLayer = new GridLayer(mgrsGrid);
  map.layerTree.addChild(mgrsGridLayer);

  // create an overlay div element, centered at the top of the map
  const overlayDiv = document.createElement("div");
  overlayDiv.id = "mgrs-overlay-div";
  overlayDiv.style.zIndex = "10";
  overlayDiv.style.position = "absolute";
  overlayDiv.style.top = "15px";
  overlayDiv.style.left = "50%";
  overlayDiv.style.transform = "translate(-50%, 0)";
  overlayDiv.style.color = "yellow";
  overlayDiv.style.fontSize = "3em";
  overlayDiv.style.pointerEvents = "none";
  map.domNode.appendChild(overlayDiv);

  // create a MGRS overlay text provider
  const overlaySettings = createDefaultMGRSOverlayTextSettings(mgrsGrid);
  const overlayTextProvider = new MGRSGridOverlayTextProvider(mgrsGridLayer, overlaySettings,{coordinate: OverlayTextCoordinateType.COMMON_MAP_COORDINATE});

  overlayDiv.style.display = "none"
  const visibilityChangedHandle = overlayTextProvider.on("VisibilityChanged", () => {
    overlayDiv.style.display = "block";
  });

  overlayDiv.innerText = overlayTextProvider.text;
  const textChangedHandle = overlayTextProvider.on("TextChanged", () => {
    overlayDiv.innerText = overlayTextProvider.text;
  });

  function destroyUI() {
    visibilityChangedHandle.remove();
    textChangedHandle.remove();
    overlayTextProvider.destroy();
    map.domNode.removeChild(overlayDiv);
  }
since

2022.0

Hierarchy

Implements

Overview

Constructors

constructor

Events

on

  • (event: "TextChanged", callback: (newText: string) => void): Handle
  • (event: "VisibilityChanged", callback: (newVisibility: boolean) => void): Handle

Accessors

text

  • get text(): string

visible

  • get visible(): boolean
  • Returns the current state of visibility. Visible is true when:

    • the layer is added to a map
    • the layer's Layer.visible is true
    • labeling is turned on for the current layer

    Returns boolean

Methods

destroy

  • (): void
  • Destroy this OverlayTextProvider. This cleans up all map / layer listeners it has set up.

    Returns void

Protected formatCommonMapCoordinate

  • (map: Map, aFormat: string): string

Protected formatModelPoint

  • (modelPoint: Point, format: string): string

Protected update

  • (): void

Protected viewPointToModel

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method