require(["esri/SpatialReference"], function(SpatialReference) { /* code goes here */ });
Description
(Added at v1.0)
Defines the spatial reference of a map, layer, or task parameters. This indicates the Projected or Geographic Coordinate System used to locate geographic features in the map. Each coordinate system is defined by either a well-known ID (WKID) or a definition string (WKT). Note that for versions prior to ArcGIS 10, only
wkid
was supported.
For a full list of supported spatial reference IDs and their corresponding definition strings, see
Using spatial references.
Samples
Search for
samples that use this class.
Subclasses
Constructors
Properties
wkid | Number | The well-known ID of a spatial reference. |
wkt | String | The well-known text that defines a spatial reference. |
Methods
equals(sr) | Boolean | Returns true if the input spatial reference object has the same wkid or wkt as this spatial reference object. |
isWebMercator() | Boolean | Returns true if the wkid of the spatial reference object is one of the following values: 102113, 102100, 3857. |
toJson() | Object | Returns an easily serializable object representation of the spatial reference. |
Constructor Details
Creates a new SpatialReference object.
Parameters:
<Object > json |
Required |
The REST JSON representation of the spatial reference. {"wkid" : <wkid>} |
Sample: Specify the spatial reference using either well-known text (wkt) or a well-known id (wkid). Note that pre 10 only wkid was supported.
require([
"esri/SpatialReference", ...
], function(SpatialReference, ... ) {
var spatialReference = new SpatialReference({wkid:32662});
var spatialReference2 = new SpatialReference({"wkt": 'PROJCS["NAD_1983_HARN_StatePlane_Oregon_North_FIPS_3601",' +
'GEOGCS["GCS_North_American_1983_HARN",DATUM["D_North_American_1983_HARN",' +
'SPHEROID["GRS_1980",6378137.0,298.257222101]]' +
'PRIMEM["Greenwich",0.0],' +
'UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],' +
'PARAMETER["False_Easting",8202099.737532808],PARAMETER["False_Northing",0.0],' +
'PARAMETER["Central_Meridian",-120.5],' +
'PARAMETER["Standard_Parallel_1",44.33333333333334],' +
'PARAMETER["Standard_Parallel_2",46.0],' +
'PARAMETER["Latitude_Of_Origin",43.66666666666666],UNIT["Foot",0.3048]]'
});
...
});
Create a spatial reference object and initialize it with a well-known ID (wkid). (Added at v2.8)
Parameters:
<Number > wkid |
Required |
The well-known id (wkid) of the coordinate system. |
Sample:
require([
"esri/SpatialReference", ...
], function(SpatialReference, ... ) {
var sr = new SpatialReference(4326);
...
});
Create a spatial reference object and initialize it with the given well-known text (wkt). (Added at v2.8)
Parameters:
<String > wkt |
Required |
The well-known text (wkt) of the coordinate system. |
Sample:
require([
"esri/SpatialReference", ...
], function(SpatialReference, ... ) {
var sr = new SpatialReference('GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",
SPHEROID["WGS_1984",6378137.0,298.257223563]],
PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'
);
...
});
Property Details
The well-known text that defines a spatial reference.
Method Details
Returns true if the input spatial reference object has the same wkid or wkt as this spatial reference object. Returns false otherwise. (Added at v3.3)
Sample:
require(["esri/SpatialReference"], function(SpatialReference) {
var sr1 = new SpatialReference(4326);
var sr2 = new SpatialReference(4326);
console.log(sr1.equals(sr2)); // true
});
Returns true if the wkid of the spatial reference object is one of the following values: 102113, 102100, 3857. (Added at v3.3)
Sample:
require([
"esri/SpatialReference", ...
], function(SpatialReference, ... ) {
var sr = new SpatialReference(102100);
console.log(sr.isWebMercator()); // true
...
});
Returns an easily serializable object representation of the spatial reference.