webMercatorUtils

AMD: require(["esri/geometry/support/webMercatorUtils"], (webMercatorUtils) => { /* code goes here */ });
ESM: import * as webMercatorUtils from "@arcgis/core/geometry/support/webMercatorUtils";
Object: esri/geometry/support/webMercatorUtils
Since: ArcGIS API for JavaScript 4.0

Converts Web Mercator coordinates to geographic coordinates and vice versa.

Method Overview

Name Return Type Summary Object
Booleanmore details

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.

more detailswebMercatorUtils
Geometrymore details

Converts a geometry from geographic units (wkid: 4326) to Web Mercator units (wkid: 3857).

more detailswebMercatorUtils
Number[]more details

Translates the given latitude and longitude (decimal degree) values to Web Mercator XY values.

more detailswebMercatorUtils
Geometrymore details

Projects the geometry clientside (if possible).

more detailswebMercatorUtils
Geometrymore details

Converts a geometry from Web Mercator units (wkid: 3857) to geographic units (wkid: 4326).

more detailswebMercatorUtils
Number[]more details

Translates the given Web Mercator coordinates to Longitude and Latitude values (decimal degrees).

more detailswebMercatorUtils

Method Details

canProject(source, target){Boolean}

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.

Parameters:

The input SpatialReference or an object with spatialReference property such as Geometry or Map.

The target SpatialReference or an object with spatialReference property such as Geometry or Map.

Returns:
Type Description
Boolean Returns true if source can be projected to target.
See also:
geographicToWebMercator(geometry){Geometry}

Converts a geometry from geographic units (wkid: 4326) to Web Mercator units (wkid: 3857).

Parameter:
geometry Geometry

The input geometry to convert.

Returns:
Type Description
Geometry Returns the converted geometry in Web Mercator units.
lngLatToXY(long, lat){Number[]}

Translates the given latitude and longitude (decimal degree) values to Web Mercator XY values.

Parameters:
long Number

The longitude value to convert.

lat Number

The latitude value to convert.

Returns:
Type Description
Number[] Returns the converted values in an array.
project(geometry, spatialReference){Geometry}

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 GeometryService.project() instead.

Parameters:
geometry Geometry

The input geometry.

spatialReference SpatialReference|Object

The target SpatialReference or an object with spatialReference property such as Geometry or Map.

Returns:
Type Description
Geometry Returns the projected geometry if the projection is successful.
See also:
webMercatorToGeographic(geometry){Geometry}

Converts a geometry from Web Mercator units (wkid: 3857) to geographic units (wkid: 4326).

Parameter:
geometry Geometry

The input geometry to convert.

Returns:
Type Description
Geometry Returns the converted geometry in geographic units.
xyToLngLat(x, y){Number[]}

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.

Parameters:
x Number

The X coordinate value to convert.

y Number

The Y coordinate value to convert.

Returns:
Type Description
Number[] Returns the converted values in an array.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.