SpatialReference
require(["esri/geometry/SpatialReference"], function(SpatialReference) { /* code goes here */ });
esri/geometry/SpatialReference
The spatial reference of a map, layer, or inputs to and outputs from a task. Each projected and geographic coordinate system is defined by either a well-known ID (WKID) or a definition string (WKT). Versions prior to ArcGIS 10 only supported WKID. For a full list of supported spatial reference IDs and their corresponding definition strings, see the links below.
Constructors
- new SpatialReference(properties)
- Parameter:properties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
String | The name of the class. more details | more details | Accessor | |
Boolean | Indicates if the spatial reference refers to a geographic coordinate system. more details | more details | SpatialReference | |
Boolean | Indicates if the wkid of the spatial reference object is one of the following values: | more details | SpatialReference | |
Boolean | Indicates if the wkid of the spatial reference object is | more details | SpatialReference | |
Boolean | Indicates if the spatial reference of the map supports wrapping around the International Date Line. more details | more details | SpatialReference | |
SpatialReference | A convenience spatial reference instance for Web Mercator. more details | more details | SpatialReference | |
SpatialReference | A convenience spatial reference instance for WGS84. more details | more details | SpatialReference | |
Number | The well-known ID of a spatial reference. more details | more details | SpatialReference | |
String | The well-known text that defines a spatial reference. more details | more details | SpatialReference |
Property Details
- Since: ArcGIS API for JavaScript 4.7
The name of the class. The declared class name is formatted as
esri.folder.className
.
- isGeographicBooleanreadonly
Indicates if the spatial reference refers to a geographic coordinate system.
- isWebMercatorBooleanreadonly
Indicates if the wkid of the spatial reference object is one of the following values:
102113
,102100
,3857
.
- isWrappableBooleanreadonly
Indicates if the spatial reference of the map supports wrapping around the International Date Line. Value is
true
if the spatial reference is Web Mercator or WGS84.
- WebMercatorSpatialReferencestatic
A convenience spatial reference instance for Web Mercator.
Example:// returns true if the webMercatorUtils can // project geometries from WGS84 to Web Mercator var canProjectWGS84toWebMercator = webMercatorUtils.canProject(SpatialReference.WGS84, SpatialReference.WebMercator);
- WGS84SpatialReferencestatic
A convenience spatial reference instance for WGS84.
Example:// returns true if the webMercatorUtils can // project geometries from WGS84 to Web Mercator var canProjectWGS84toWebMercator = webMercatorUtils.canProject(SpatialReference.WGS84, SpatialReference.WebMercator);
- wkidNumber
The well-known ID of a spatial reference. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.
- wktString
The well-known text that defines a spatial reference. Many browsers have a limit to the length of a GET request of approximately 2048 characters. When using well-known text to specify the spatial reference you can easily exceed this limit. In these cases, you will need to setup and use a proxy page.
Method Overview
Name | Return Type | Summary | Class | |
---|---|---|---|---|
SpatialReference | Returns a deep clone of the spatial reference object. more details | more details | SpatialReference | |
Boolean | Checks if the specified spatial reference object has the same wkid or wkt as this spatial reference object. more details | more details | SpatialReference | |
* | Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. more details | more details | SpatialReference | |
Object | Converts an instance of this class to its ArcGIS portal JSON representation. more details | more details | SpatialReference |
Method Details
- clone(){SpatialReference}
Returns a deep clone of the spatial reference object.
Returns:Type Description SpatialReference Returns a deep clone of the spatial reference object.
- equals(spatialReference){Boolean}
Checks if the specified spatial reference object has the same wkid or wkt as this spatial reference object.
Parameter:spatialReference SpatialReferenceThe spatial reference to compare to.
Returns:Type Description Boolean Returns true
if the input spatial reference object has the same wkid or wkt as this spatial reference object.Example:require(["esri/geometry/SpatialReference"], function(SpatialReference) { var sr1 = new SpatialReference(4326); var sr2 = new SpatialReference(4326); console.log(sr1.equals(sr2)); // true });
- fromJSON(json){*}static
Creates a new instance of this class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input
json
parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.Parameter:json ObjectA JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.
Returns:Type Description * Returns a new instance of this class.
- toJSON(){Object}
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() topic in the Guide for more information.
Returns:Type Description Object The ArcGIS portal JSON representation of an instance of this class.