Hide Table of Contents
esri
Map
toolbars
Class: Point
[ AMD Module Require | Legacy Module Require ]

Module Require

require(["esri/geometry/Point", ... ], function(Point, ... ){ ... });

Description

A location defined by an X- and Y- coordinate. It can be map units or screen units.

Samples

Search for samples that use this class.

Class hierarchy

esri.geometry.Geometry
|_esri.geometry.Point

Constructors

ConstructorDescription
new Point(x,y,spatialReference)Creates a new Point object using x, y, and a spatial reference. At version 3.3 if a spatial reference is not provided a default spatial reference of 4326 will be assigned.
new Point([x,y],spatialReference)Creates a new Point object using an array containing an x,y coordinate value and a spatial reference. At version 3.3 if a spatial reference is not provided a default spatial reference of 4326 will be assigned. 
new Point(json)Creates a new Point object using a JSON object.  
new Point(long,lat)Create a point object and initialize it with the specified longitude and latitude. 
new Point(point)Create a point object and initialize it with an array containing longitude and latitude values. 
new Point(point)Create a point object and initialize it with an object that has latitude and longitude properties. 

Properties

PropertyTypeDescription
spatialReferenceSpatialReferenceThe spatial reference of the geometry. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.
typeStringThe type of geometry.
xNumberX-coordinate of a point in map units.
yNumberY-coordinate of a point in map units.

Methods

MethodReturn ValueDescription
getLatitude()NumberReturns the latitude coordinate for this point if the spatial reference of the point is Web Mercator or Geographic (4326). 
getLongitude()NumberReturns the longitude coordinate for this point if the spatial reference of the point is Web Mercator or Geographic (4326). 
offset(dx,dy)PointOffsets the point in an x and y direction. Units are map units.
setLatitude(lat)PointSets the latitude coordinate for this point to the specified value if the point's spatial reference is Web Mercator or Geographic (4326). 
setLongitude(lon)PointSets the longitude coordinate for this point to the specified value if the point's spatial reference is Web Mercator or Geographic (4326). 
setSpatialReference(sr)GeometrySets the spatial reference.

The return value of Geometry was added at v1.4.
setX(x)PointSets x-coordinate of point.

The return value of Point was added at v1.4.
setY(y)PointSets y-coordinate of point.

The return value of Point was added at v1.4.
toJson()ObjectConverts object to its ArcGIS Server JSON representation.
update(x,y)PointUpdates a point.
Constructor Details

new Point(x,y,spatialReference)

Creates a new Point object using x, y, and a spatial reference. At version 3.3 if a spatial reference is not provided a default spatial reference of 4326 will be assigned.
Parameters:
<Number> xRequiredX-coordinate of a point in map units.
<Number> yRequiredY-coordinate of a point in map units.
<SpatialReference> spatialReferenceRequiredSpatial reference of the geometry.
Code Snippet:
require([
  "esri/geometry/Point", "esri/SpatialReference", ... 
], function(Point, SpatialReference, ... ) {
  new Point(-118.15, 33.80, new SpatialReference({ wkid: 4326 }));
  ...
});

new Point([x,y],spatialReference)

Creates a new Point object using an array containing an x,y coordinate value and a spatial reference. At version 3.3 if a spatial reference is not provided a default spatial reference of 4326 will be assigned. 
Parameters:
<Array> [x,y]RequiredAn array that includes an x,y coordinate.
<SpatialReference> spatialReferenceRequiredSpatial reference of the geometry.
Code Snippet:
require([
  "esri/geometry/Point", "esri/SpatialReference", ... 
], function(Point, SpatialReference, ... ) {
  var point = new Point([-122.65,45.53],new SpatialReference({ wkid:4326 }));
  ...
});

new Point(json)

Creates a new Point object using a JSON object.  
Parameters:
<Object> jsonRequiredA JSON object that contains an x,y coordinate.
Code Snippet:
require([
  "esri/geometry/Point", ... 
], function(Point, ... ) {
  var point = new Point( {"x": -122.65, "y": 45.53, "spatialReference": {"wkid": 4326 } });
  ...
});

new Point(long,lat)

Create a point object and initialize it with the specified longitude and latitude. 
Parameters:
<Number> longRequiredLongitude value. 
<Number> latRequiredLatitude value.
Code Snippet:
require([
  "esri/geometry/Point", ... 
], function(Point, ... ) {
  var point = new Point(-98, 38);
  ...
});

new Point(point)

Create a point object and initialize it with an array containing longitude and latitude values. 
Parameters:
<Number[]> pointRequiredAn input array containing the longitude and latitude values for the point. 
Code Snippet:
require([
  "esri/geometry/Point", ... 
], function(Point, ... ) {
  var point = new Point([-98, 38]);
  ...
});

new Point(point)

Create a point object and initialize it with an object that has latitude and longitude properties. 
Parameters:
<Object> pointRequiredAn object with latitude and longitude properties. 
Code Snippet:
require([
  "esri/geometry/Point", ... 
], function(Point, ... ) {
  var point = new Point({
    latitude: 38,
    longitude: -98
  });
  ...
});
Property Details

<SpatialReference> spatialReference

The spatial reference of the geometry. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.

<String> type

The type of geometry.
Known Values: point | multipoint | polyline | polygon | extent

<Number> x

X-coordinate of a point in map units.

<Number> y

Y-coordinate of a point in map units.
Method Details

getLatitude()

Returns the latitude coordinate for this point if the spatial reference of the point is Web Mercator or Geographic (4326). 
Return Value: Number

getLongitude()

Returns the longitude coordinate for this point if the spatial reference of the point is Web Mercator or Geographic (4326). 
Return Value: Number

offset(dx,dy)

Offsets the point in an x and y direction. Units are map units.
Return Value: Point
Input Parameters:
<Number> dxRequiredValue for x-coordinate of point.
<Number> dyRequiredValue for y-coordinate of point.

setLatitude(lat)

Sets the latitude coordinate for this point to the specified value if the point's spatial reference is Web Mercator or Geographic (4326). 
Return Value: Point
Input Parameters:
<Number> latRequiredValid latitude value. 

setLongitude(lon)

Sets the longitude coordinate for this point to the specified value if the point's spatial reference is Web Mercator or Geographic (4326). 
Return Value: Point
Input Parameters:
<Number> lonRequiredA valid longitude value.

setSpatialReference(sr)

Sets the spatial reference.

The return value of Geometry was added at v1.4.
Return Value: Geometry
Input Parameters:
<SpatialReference> srRequiredSpatial reference of the geometry.

setX(x)

Sets x-coordinate of point.

The return value of Point was added at v1.4.
Return Value: Point
Input Parameters:
<Number> xRequiredValue for x-coordinate of point.

setY(y)

Sets y-coordinate of point.

The return value of Point was added at v1.4.
Return Value: Point
Input Parameters:
<Number> yRequiredValue for y-coordinate of point.

toJson()

Converts object to its ArcGIS Server JSON representation.
Return Value: Object

update(x,y)

Updates a point.
Return Value: Point
Input Parameters:
<Number> xRequiredX-coordinate of the updated point.
<Number> yRequiredY-coordinate of the updated point.