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

    Interface CoordinateTransformer

    A CoordinateTransformer transforms Esri geometries from one coordinate reference system to another. Additionally it can be used to retrieve a list of available coordinate reference systems.

    Use coordinatetransformer.CoordinateTransformer to inject an instance of this service into your components.

    In your manifest.json:

    "components": [{
    "name": "MyComponent",
    "references": [{
    "name": "coordinateTransformer",
    "providing": "coordinatetransformer.CoordinateTransformer"
    }]
    }]

    In your code (MyComponent.ts):

    import { InjectedReference } from "apprt-core/InjectedReference";
    import { CoordinateTransformer } from "coordinatetransformer/CoordinateTransformer";
    import { Geometry } from "@arcgis/core/geometry";

    export default class MyComponent {
    private coordinateTransformer: InjectedReference<CoordinateTransformer>;
    async transformToWGS84(geometry: Geometry): Promise<Geometry> {
    const wgs84Code = 4326;
    const transformedGeometry =
    await this.coordinateTransformer!.transform(geometry, wgs84Code);
    return transformedGeometry;
    }
    }
    interface CoordinateTransformer {
        getProjection(srsCode: SrsParam): undefined | Projection;
        getProjections(): Promise<Projection[]>;
        transform<G extends Geometry>(
            geometry: G,
            targetSRS: SrsParam,
            coordinateModificationCallback?: CoordinateModificationCallback,
        ): Promise<G>;
        transformExtent(
            extent: Extent,
            scale: number,
            targetSRS: SrsParam,
        ): Promise<Extent>;
    }
    Index

    Methods

    • Function to retrieve projection metadata for an EPSG code.

      Parameters

      Returns undefined | Projection

      resolving to a metadata object describing a projection.

    • Returns a list of metadata objects for available projections.

      Returns Promise<Projection[]>

      a list of all available projections.

    • Transforms a geometry or an array of geometries.

      Type Parameters

      • G extends Geometry

      Parameters

      • geometry: G

        input geometry (may also be an array of geometries)

      • targetSRS: SrsParam

        target code for transformation

      • OptionalcoordinateModificationCallback: CoordinateModificationCallback

        can be used to pre-process point coordinates before transformation

      Returns Promise<G>

      the transformed geometry (if input was an array, output will be an array of transformed geometries)

    • Dedicated function to transform an extent based on center and scale.

      Parameters

      • extent: Extent

        input extent, which center is used

      • scale: number

        target scale for transformation

      • targetSRS: SrsParam

        SRS for transformation

      Returns Promise<Extent>

      the transformed extent