import * as webMercatorUtils from "@arcgis/core/geometry/support/webMercatorUtils.js";
const webMercatorUtils = await $arcgis.import("@arcgis/core/geometry/support/webMercatorUtils.js");
@arcgis/core/geometry/support/webMercatorUtils
Converts Web Mercator coordinates to geographic coordinates and vice versa.
Known Limitation
Geometry type Mesh is not supported.
Method Overview
| Name | Return Type | Summary | Object |
|---|---|---|---|
Returns | webMercatorUtils | ||
Converts a geometry from geographic units (wkid: 4326) to Web Mercator units (wkid: 3857). | webMercatorUtils | ||
Translates the given latitude and longitude (decimal degree) values to Web Mercator XY values. | webMercatorUtils | ||
Projects the geometry clientside (if possible). | webMercatorUtils | ||
Converts a geometry from Web Mercator units (wkid: 3857) to geographic units (wkid: 4326). | webMercatorUtils | ||
Translates the given Web Mercator coordinates to Longitude and Latitude values (decimal degrees). | webMercatorUtils |
Method Details
-
canProject
MethodcanProject(source, target){Boolean} -
Returns
trueif thesourcespatial reference can be projected to thetargetspatial reference with the project() function, or if thesourceandtargetare the same SpatialReference.Parameterssource SpatialReference|ObjectThe input SpatialReference or an object with
spatialReferenceproperty such as Geometry or Map.target SpatialReference|ObjectThe target SpatialReference or an object with
spatialReferenceproperty such as Geometry or Map.ReturnsType Description Boolean Returns trueifsourcecan be projected totarget.- See also
-
geographicToWebMercator
MethodgeographicToWebMercator(geometry){GeometryUnion} -
Converts a geometry from geographic units (wkid: 4326) to Web Mercator units (wkid: 3857).
Parametergeometry GeometryUnionThe input geometry to convert.
ReturnsType Description GeometryUnion Returns the converted geometry in Web Mercator units.
-
Translates the given latitude and longitude (decimal degree) values to Web Mercator XY values.
Returns
-
project
Methodproject(geometry, spatialReference){GeometryUnion |null |undefined} -
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() returnsfalse, thenproject()won't return useful results. Use geometryService.project() instead.Parametersgeometry GeometryUnion|null|undefinedThe input geometry.
spatialReference SpatialReference|ObjectThe target SpatialReference or an object with
spatialReferenceproperty such as Geometry or Map.ReturnsType Description GeometryUnion | null | undefined Returns the projected geometry if the projection is successful.
-
webMercatorToGeographic
MethodwebMercatorToGeographic(geometry, isLinear){GeometryUnion} -
Converts a geometry from Web Mercator units (wkid: 3857) to geographic units (wkid: 4326).
Parametersgeometry GeometryUnionThe input geometry to convert.
isLinear BooleanoptionalDefault Value: falseIndicates 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
true. Default value isfalse.ReturnsType Description GeometryUnion Returns the converted geometry in geographic units.
-
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.
Returns