ESM: import SpatialReference from "@arcgis/core/geometry/SpatialReference.js";
CDN: const SpatialReference = await $arcgis.import("@arcgis/core/geometry/SpatialReference.js");
Class: @arcgis/core/geometry/SpatialReference
Since: ArcGIS Maps SDK for JavaScript 4.0
Defines the spatial reference of a view, layer, or method parameters. This indicates the projected or geographic coordinate system used to locate geographic features in the map. Each projected and geographic 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.
Examples
// set the spatial reference of a view to WebMercator using wkid
const view = new SceneView({
container: "viewDiv",
map: map,
spatialReference: {
wkid: 3857
}
});
// set the spatial reference of a geometry
// to WGS84 using the WGS84 property
const point = new Point({
x: 10.1,
y: 47.4,
spatialReference: SpatialReference.WGS84
});
Constructors
new SpatialReference(properties)
Parameter
optionalSee the properties for a list of all the properties that may be passed into the constructor.
Show inherited properties Hide inherited properties
Property DetailsA convenience spatial reference instance for WGS84.
Example
// returns true if the webMercatorUtils can
// project geometries from WGS84 to Web Mercator
let canProjectWGS84toWebMercator = webMercatorUtils.canProject(SpatialReference.WGS84, SpatialReference.WebMercator);
A convenience spatial reference instance for Web Mercator.
Example
// returns true if the webMercatorUtils can
// project geometries from WGS84 to Web Mercator
let canProjectWGS84toWebMercator = webMercatorUtils.canProject(SpatialReference.WGS84, SpatialReference.WebMercator);
Inherited
Property declaredClass Stringreadonly
Since: ArcGIS Maps SDK for JavaScript 4.7 Accessor since 4.0, declaredClass added at 4.7.
The name of the class. The declared class name is formatted as esri.folder.className
.
Since: ArcGIS Maps SDK for JavaScript 4.13 SpatialReference since 4.0, imageCoordinateSystem added at 4.13.
An image coordinate system defines the spatial reference used to display the image in its original coordinates without distortion, map transformations or ortho-rectification. Typically, ImageryLayer is displayed in the spatialReference of the view. In some cases, converting images into map coordinates can cause your images to look skewed or distorted because of the various transformations and terrain corrections that are used. Since there is no distortion with images in the image coordinate system, it is ideal for using with oblique imagery and mensuration.
The image can be displayed in its original coordinates only in 2D MapView with a top-up
rotation which is always oriented in the look of direction of the dataset. This works similarly to an in-car navigation system where the choices are often either north is at the top of the screen (therefore, not using a top up option) or the screen rotates so the travel direction is always displayed at the top.
Example
// get image coordinate system of the specified catalog item
// for example Raster.OBJECTID = 1600
layer.getCatalogItemICSInfo(imageId).then(function(info) {
// create a spatialReference object and set its
// imageCoordinateSystem property
let sr = { // autocasts to esri/geometry/SpatialReference
imageCoordinateSystem: { id: imageId }
};
// Calculate an extent for the mapview based on the image's extent
// in its original coordinate system
const width = document.getElementById("viewDiv").getBoundingClientRect().width;
const height = document.getElementById("viewDiv").getBoundingClientRect().height;
const newExt = info.icsExtent.clone();
const scaleFactor = 5;
newExt.xmin = (newExt.xmin + newExt.xmax - width * scaleFactor) / 2;
newExt.xmax = newExt.xmin + width * scaleFactor;
newExt.ymin = (newExt.ymin + newExt.ymax - height * scaleFactor) / 2;
newExt.ymax = newExt.ymin + height * scaleFactor;
newExt.spatialReference = sr;
// set the MapView's spatialReference to the image's coordinate system
// and the extent to the extent calculated above
view = new MapView({
container: "viewDiv",
map: map,
spatialReference: sr,
extent: newExt
});
});
isGeographic Booleanreadonly
Indicates if the spatial reference refers to a geographic coordinate system.
isWGS84 Booleanreadonly
Indicates if the wkid of the spatial reference object is 4326
.
isWebMercator Booleanreadonly
Indicates if the wkid of the spatial reference object is one of the following values: 102113
, 102100
, 3857
.
isWrappable Booleanreadonly
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.
metersPerUnit Numberreadonly
Since: ArcGIS Maps SDK for JavaScript 4.26 SpatialReference since 4.0, metersPerUnit added at 4.26.
The factor to convert one unit value in the spatial reference's unit to meters.
Examples
// Convert 1 pixel in a MapView to meters
const pixelInMeter = view.resolution * view.spatialReference.metersPerUnit;
// Measure the geodesic distance between two points in the view's unit
const distanceInViewUnit = geodesicUtils.geodesicDistance(pointA, pointB, "meters") / view.spatialReference.metersPerUnit;
const DPI = 96
const inchesPerMeter = 39.37;
// Get the scale for an extent
function getScale(extent, viewWidth) {
const unitValue = extent.spatialReference.metersPerUnit;
return (extent.width / viewWidth) * unitValue * inchesPerMeter * DPI;
}
Since: ArcGIS Maps SDK for JavaScript 4.26 SpatialReference since 4.0, unit added at 4.26.
The unit of the spatial reference. Returns null
if no unit could be determined.
Some values of the possible values listed here cannot be used as parameters for certain functions. For example, geodesicUtils.geodesicDistance() only accepts meters
, feet
, us-feet
. For other values, you can use the meters
unit and use metersPerUnit convert to the spatial reference's unit
.
Possible Values:"150-kilometers" |"1865-feet" |"50-kilometers" |"benoit-1895-a-chains" |"benoit-1895-a-feet" |"benoit-1895-a-links" |"benoit-1895-a-yards" |"benoit-1895-b-chains" |"benoit-1895-b-feet" |"benoit-1895-b-links" |"benoit-1895-b-yards" |"british-1936-feet" |"centimeters" |"chains" |"clarke-chains" |"clarke-feet" |"clarke-links" |"clarke-yards" |"decimeters" |"fathoms" |"feet" |"german-meters" |"gold-coast-feet" |"inches" |"indian-1937-feet" |"indian-1937-yards" |"indian-1962-feet" |"indian-1962-yards" |"indian-1975-feet" |"indian-1975-yards" |"indian-feet" |"indian-yards" |"kilometers" |"links" |"meters" |"micrometers" |"millimeters" |"nanometers" |"nautical-miles" |"points" |"rods" |"sears-1922-truncated-chains" |"sears-1922-truncated-feet" |"sears-1922-truncated-links" |"sears-1922-truncated-yards" |"sears-chains" |"sears-feet" |"sears-links" |"sears-yards" |"smoots" |"statute-miles" |"tx-vara" |"uk-nautical-miles" |"us-chains" |"us-feet" |"us-inches" |"us-links" |"us-miles" |"us-nautical-miles" |"us-rods" |"us-yards" |"yards" |"degrees"
The well-known text that defines a spatial reference.
Since: ArcGIS Maps SDK for JavaScript 4.28 SpatialReference since 4.0, wkt2 added at 4.28.
The well-known text of the coordinate system as defined by OGC standard for well-known text strings.
Show inherited methods Hide inherited methods
Method DetailsInherited
Method addHandles(handleOrHandles, groupKey)
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles
const handle = reactiveUtils.when(
() => !view.updating,
() => {
wkidSelect.disabled = false;
},
{ once: true }
);
this.addHandles(handle);
// Destroy the object
this.destroy();
Parameters
Handles marked for removal once the object is destroyed.
groupKey *
optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
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.
Returns
Type Description Boolean Returnstrue
if the input spatial reference object has the same wkid or wkt as this spatial reference object.
Example
const SpatialReference = await $arcgis.import("@arcgis/core/geometry/SpatialReference.js");
const sr1 = new SpatialReference({ wkid: 4326 });
const sr2 = new SpatialReference({ wkid: 4326 });
console.log(sr1.equals(sr2)); // true
Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. 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.
Returns
Type Description * | null | undefined Returns a new instance of this class.Inherited
Method hasHandles(groupKey){Boolean}
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.
Returns true if a named group of handles exist.
Parameter
groupKey *
optionalA group key.
Returns
Type Description Boolean Returnstrue
if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
obj.removeHandles("watch-view-updates");
}
Inherited
Method removeHandles(groupKey)
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.
Removes a group of handles owned by the object.
Parameter
groupKey *
optionalA group key or an array or collection of group keys to remove.
Example
obj.removeHandles(); // removes handles from default group
obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4