map.apps Bundle APIs 4.20.0
    Preparing search index...

    Implements a format for coordinate conversions.

    You can extend the builtin set of formats by providing a service with "coordinateconversion.SegmentedFormat".

    interface SegmentedFormat {
        id: string;
        label: string;
        pointToSegments(point: Point): Promise<Record<string, string>>;
        segments: CoordinateSegment[];
        segmentsToPoint(
            segments: Record<string, string>,
        ): Promise<ParseResult<Point>>;
        segmentsToString(segments: Record<string, string>): string;
        spatialReference?: SpatialReference;
        stringToSegments(input: string): ParseResult<Record<string, string>>;
    }
    Index

    Properties

    id: string

    Unique id of this format.

    label: string

    Human readable label of this format.

    segments: CoordinateSegment[]

    Input segments required by the format, for example x and y coordinates. The coordinate conversion widget shows one input field for each segment.

    spatialReference?: SpatialReference

    When specified, points will be projected to this spatial reference before being passed to pointToSegments.

    If this is not specified, you will receive the point in the current spatial reference of the view, and you will have to perform any necessary projections yourself.

    Methods

    • Renders a point to segment values. The returned record is indexed by segment ids and contains a string for each segment.

      The output of this function should be compatible with segmentsToPoint.

      Example:

      const point = ...;
      const segments = format.pointToSegments(point);
      // segments == { x: "...", y: "..." }

      Parameters

      • point: Point

      Returns Promise<Record<string, string>>

    • Parses a set of (validated) segment values into a Point. This can be used, for example, to place a marker on the map.

      Example:

      const segments = { x: "1", y: "2" }
      const point = await format.segmentsToPoint(segments).value; // assumes success
      // point == { x: 1234, y: 5678, spatialReference: { ... }}

      Parameters

      • segments: Record<string, string>

      Returns Promise<ParseResult<Point>>

    • Formats a set of segment values to a human readable string. This combines the segment values to a final display string, including separating characters (like ',' or ' ') and units (like '°' and '"').

      The segments parameter can be assumed to contain valid strings: either

      The value returned here should be compatible with stringToSegments.

      Example:

      const segments = { x: "1", y: "2" }
      const output = format.segmentsToString(segments);
      // output == "1°, 2°"

      Parameters

      • segments: Record<string, string>

      Returns string

    • Splits a human readable coordinates string (like returned by segmentsToString) into its input segment.

      For example:

      const input = "123.4 567.8";
      const segments = format.stringToSegments(input).value; // assumes success
      // segments == { x: "123.4", y: "567.8" };

      Parameters

      • input: string

      Returns ParseResult<Record<string, string>>