Skip to content
import ControlPointsGeoreference from "@arcgis/core/layers/support/ControlPointsGeoreference.js";
Inheritance:
ControlPointsGeoreferenceAccessor
Since
ArcGIS Maps SDK for JavaScript 4.25

ControlPointsGeoreference is used to set the geographic location of the ImageElement or VideoElement referenced in the MediaLayer using the controlPoints, width, and height parameters. The element is positioned, scaled, and rotated with two controlPoints. Additionally, it will be skewed with three controlPoints. With four controlPoints, a perspective transformation is applied to the element.

// the spatial reference for the MediaLayer, North American Datum 1927
const spatialReference = new SpatialReference({ wkid: 4267 });
// create an array of four control points composed of a sourcePoint, a point
// on the image element in pixels, and a mapPoint which is the location of the
// sourcePoint in map space
const swCorner = {
sourcePoint: { x: 80, y: 1732 },
mapPoint: new Point({ x: -107.875, y: 37.875, spatialReference })
};
const nwCorner = {
sourcePoint: { x: 75, y: 102 },
mapPoint: new Point({ x: -107.875, y: 38, spatialReference })
};
const neCorner = {
sourcePoint: { x: 1353, y: 99 },
mapPoint: new Point({ x: -107.75, y: 38, spatialReference })
};
const seCorner = {
sourcePoint: { x: 1361, y: 1721 },
mapPoint: new Point({ x: -107.75, y: 37.875, spatialReference })
};
const controlPoints = [swCorner, nwCorner, neCorner, seCorner];
// georeference for the imageElement using the control points,
// image width, and image height
const georeference = new ControlPointsGeoreference({ controlPoints, width: 1991, height: 2500 });
const imageElement = new ImageElement({
image: "https://jsapi.maps.arcgis.com/sharing/rest/content/items/1a3df04e7d734535a3a6a09dfec5a6b2/data",
georeference
});
// create a MediaLayer using the georeferenced ImageElement
const mediaLayer = new MediaLayer({
source: [imageElement],
title: "Geologic Map of the Telluride Quadrangle, Southwestern Colorado",
copyright: "Wilbur S Burbank and Robert G. Luedke, 1966",
opacity: 0.5,
spatialReference
});
See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
PropertyTypeClass
declaredClass
readonly inherited
type
readonly
"control-points"

controlPoints

autocast Property
Type
ControlPoints | null | undefined

An array of two, three, or four controlPoints positions the media element. The element is positioned, scaled, and rotated with two controlPoints. Additionally, it will be skewed with three controlPoints. With four controlPoints, a perspective transformation is applied to the element.

Example
const swCorner = {
sourcePoint: { x: 80, y: 1732 },
mapPoint: new Point({ x: -107.875, y: 37.875, spatialReference })
};
const neCorner = {
sourcePoint: { x: 1353, y: 99 },
mapPoint: new Point({ x: -107.75, y: 38, spatialReference })
};
const controlPoints = [swCorner, neCorner];

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

height

Property
Type
number

Defines the size of the element displayed, typically the element's height in pixels. This property is used alongside controlPoints and width to position the element.

Default value
0

type

readonly Property
Type
"control-points"

width

Property
Type
number

Defines the size of the element displayed, typically the element's width in pixels. This property is used alongside controlPoints and height to position the element.

Default value
0

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
clone
inherited
clone(): this
toJSON
inherited
toJSON(): any
toMap(sourcePoint: ScreenPoint | null | undefined): Point | null | undefined
toSource(point: Point | null | undefined): ScreenPoint | null | undefined

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

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.

Parameters
ParameterTypeDescriptionRequired
json
any

A 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
any

Returns a new instance of this class.

clone

inherited Method
Signature
clone (): this
Inherited from: ClonableMixin

Creates a deep clone of this object. Any properties that store values by reference will be assigned copies of the referenced values on the cloned instance.

Returns
this

A deep clone of the class instance that invoked this method.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
any

The ArcGIS portal JSON representation of an instance of this class.

toMap

Method
Signature
toMap (sourcePoint: ScreenPoint | null | undefined): Point | null | undefined

Converts the given ScreenPoint to a mapPoint. The ScreenPoint represents a point in terms of pixels relative to the top-left corner of the element.

Parameters
ParameterTypeDescriptionRequired
sourcePoint

The location on the element.

Returns
Point | null | undefined

The mapPoint corresponding to the given ScreenPoint, in the spatial reference found in the mapPoint of the first control point.

Example
const mapPoint = controlPointGeoreference.toMap({x: 100, y: 250})

toSource

Method
Signature
toSource (point: Point | null | undefined): ScreenPoint | null | undefined

Converts the given mapPoint to a ScreenPoint. The ScreenPoint represents a point in terms of pixels relative to the top-left corner of the element.

Parameters
ParameterTypeDescriptionRequired
point

A point geometry. In the case where the point is not in the same spatial reference as the one in the mapPoint of the first control point, it will be reprojected. The projectOperator would need to be loaded to perform the reprojection, otherwise null is returned.

Returns
ScreenPoint | null | undefined

The location on the element corresponding to the given mapPoint.

Example
// North_American_Datum_1927
const spatialReference = new SpatialReference({ wkid: 4267 });
const sourcePoint = controlPointGeoreference.toSource(new Point({ x: -107.875, y: 37.875, spatialReference }))