webMercatorUtils

require(["esri/geometry/support/webMercatorUtils"], function(webMercatorUtils) { /* code goes here */ });
Object: esri/geometry/support/webMercatorUtils
Since: ArcGIS API for JavaScript 4.0

Converts Web Mercator coordinates to geographic coordinates and vice versa.

Method Overview

NameReturn TypeSummary
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.

more details
more details
Geometry

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

more details
more details
Number[]

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

more details
more details
Geometry

Projects the geometry clientside (if possible).

more details
more details
Geometry

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

more details
more details
Number[]

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

more details
more details

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:
TypeDescription
BooleanReturns 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:
TypeDescription
GeometryReturns 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:
TypeDescription
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:
TypeDescription
GeometryReturns 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:
TypeDescription
GeometryReturns 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:

The X coordinate value to convert.

The Y coordinate value to convert.

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

API Reference search results

NameTypeModule

There were no match results from your search criteria.