webMercatorUtils
require(["esri/geometry/support/webMercatorUtils"], function(webMercatorUtils) { /* code goes here */ });
esri/geometry/support/webMercatorUtils
Converts Web Mercator coordinates to geographic coordinates and vice versa.
Method Overview
Name | Return Type | Summary | Object | |
---|---|---|---|---|
Boolean | Returns | more details | webMercatorUtils | |
Geometry | Converts a geometry from geographic units (wkid: 4326) to Web Mercator units (wkid: 3857). more details | more details | webMercatorUtils | |
Number[] | Translates the given latitude and longitude (decimal degree) values to Web Mercator XY values. more details | more details | webMercatorUtils | |
Geometry | Projects the geometry clientside (if possible). more details | more details | webMercatorUtils | |
Geometry | Converts a geometry from Web Mercator units (wkid: 3857) to geographic units (wkid: 4326). more details | more details | webMercatorUtils | |
Number[] | Translates the given Web Mercator coordinates to Longitude and Latitude values (decimal degrees). more details | more details | webMercatorUtils |
Method Details
- canProject(source, target){Boolean}
Returns
true
if thesource
spatial reference can be projected to thetarget
spatial reference with the project() function, or if thesource
andtarget
are the same SpatialReference.Parameters:source SpatialReference|ObjectThe input SpatialReference or an object with
spatialReference
property such as Geometry or Map.target SpatialReference|ObjectThe target SpatialReference or an object with
spatialReference
property such as Geometry or Map.Returns:Type Description Boolean Returns true
ifsource
can be projected totarget
.- See also:
- geographicToWebMercator(geometry){Geometry}
Converts a geometry from geographic units (wkid: 4326) to Web Mercator units (wkid: 3857).
Parameter:geometry GeometryThe input geometry to convert.
Returns:Type Description Geometry Returns the converted geometry in Web Mercator units.
Translates the given latitude and longitude (decimal degree) values to Web Mercator XY values.
Parameters:long NumberThe longitude value to convert.
lat NumberThe 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() returnsfalse
, thenproject()
won't return useful results. Use GeometryService.project() instead.Parameters:geometry GeometryThe input geometry.
spatialReference SpatialReference|ObjectThe 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.
- webMercatorToGeographic(geometry){Geometry}
Converts a geometry from Web Mercator units (wkid: 3857) to geographic units (wkid: 4326).
Parameter:geometry GeometryThe input geometry to convert.
Returns:Type Description Geometry 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.
Parameters:x NumberThe X coordinate value to convert.
y NumberThe Y coordinate value to convert.
Returns:Type Description Number[] Returns the converted values in an array.