import { canProject, project, lngLatToXY, xyToLngLat, geographicToWebMercator } from "@arcgis/core/geometry/support/webMercatorUtils.js";const { canProject, project, lngLatToXY, xyToLngLat, geographicToWebMercator } = await $arcgis.import("@arcgis/core/geometry/support/webMercatorUtils.js");- Since
- ArcGIS Maps SDK for JavaScript 4.0
Converts Web Mercator coordinates to geographic coordinates and vice versa.
Known Limitation
Geometry type Mesh is not supported.
Functions
| Name | Return Type | Object |
|---|---|---|
| | ||
| | ||
| | ||
| | ||
| | ||
| |
canProject
Returns true if the source spatial reference can be projected to the target spatial reference with the project() function, or
if the source and target are the same SpatialReference.
- See also
- Signature
-
canProject (source: object | SpatialReference | null | undefined, target: object | SpatialReference | null | undefined): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| source | object | SpatialReference | null | undefined | The input SpatialReference or an object with
| |
| target | object | SpatialReference | null | undefined | The target SpatialReference or an object with
| |
- Returns
- boolean
Returns
trueifsourcecan be projected totarget.
project
Projects the geometry clientside (if possible). You should test the input geometry in canProject() prior to using this function.
If the result of canProject() is true, then proceed to project. If canProject() returns false, then
project() won't return useful results. Use project() instead.
- See also
- Signature
-
project (geometry: GeometryUnion | null | undefined, spatialReference: SpatialReference | null | undefined): GeometryUnion | null | undefined
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry. | | |
| spatialReference | The target SpatialReference or an object with
| |
- Returns
- GeometryUnion | null | undefined
Returns the projected geometry if the projection is successful.
lngLatToXY
Translates the given latitude and longitude (decimal degree) values to Web Mercator XY values.
- Signature
-
lngLatToXY (long: number, lat: number): [ number, number ]
xyToLngLat
Translates the given Web Mercator coordinates to Longitude and Latitude values (decimal degrees). By default the returned longitude is normalized so that it is within -180 and +180.
- Signature
-
xyToLngLat (x: number, y: number): [ number, number ]
geographicToWebMercator
Converts a geometry from geographic units (wkid: 4326) to Web Mercator units (wkid: 3857).
- Signature
-
geographicToWebMercator (geometry: GeometryUnion): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry to convert. | |
- Returns
- GeometryUnion
Returns the converted geometry in Web Mercator units.
webMercatorToGeographic
Converts a geometry from Web Mercator units (wkid: 3857) to geographic units (wkid: 4326).
- Signature
-
webMercatorToGeographic (geometry: GeometryUnion, isLinear?: boolean): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry to convert. | | |
| isLinear | = false - Indicates whether to work with linear values, i.e., do not normalize. By default, this conversion method normalizes xmin and xmax values.
If this is not desired, specify this value as | |
- Returns
- GeometryUnion
Returns the converted geometry in geographic units.