Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/workers
Class: Point

require(["esri/geometry/Point"], function(Point) { /* code goes here */ });

Description

(Added at v1.0)
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

NameSummary
new Point(x, y, spatialReference)Creates a new Point object using x, y, and a spatial reference.
new Point(coords, spatialReference)Creates a new Point object using an array containing an x,y coordinate value and a spatial reference.
new Point(json)Creates a new Point object using a JSON object.
new Point(long, lat)Create a point object and initialize it with 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

NameTypeSummary
cacheObjectThe cache is used to store values computed from geometries that need to cleared or recomputed upon mutation.
spatialReferenceSpatialReferenceThe spatial reference of the geometry.
typeStringThe type of geometry.
xNumberX-coordinate of a point in map units.
yNumberY-coordinate of a point in map units.

Methods

NameReturn typeSummary
clearCache()NoneSets the cache property to undefined.
getCacheValue(name)ObjectReturns the value for a named property stored in the cache.
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).
normalize()PointShifts the x coordinate to within +/- 180 span.
offset(dx, dy)PointReturns a new Point with x and y offsets.
setCacheValue(name, value)NoneSets the value for a named property stored in the cache.
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.
setX(x)PointSets x-coordinate of point.
setY(y)PointSets y-coordinate of point.
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> x Required X-coordinate of a point in map units.
<Number> y Required Y-coordinate of a point in map units.
<SpatialReference> spatialReference Required Spatial reference of the geometry.
Sample:
require([
  "esri/geometry/Point", "esri/SpatialReference", ... 
], function(Point, SpatialReference, ... ) {
  new Point(-118.15, 33.80, new SpatialReference({ wkid: 4326 }));
  ...
});

new Point(coords, 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:
<Number[]> coords Required An array that includes an x,y coordinate. For example: [-117,34].
<SpatialReference> spatialReference Required Spatial reference of the geometry.
Sample:
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> json Required A JSON object that contains an x,y coordinate.
Sample:
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 specified longitude and latitude. (Added at v3.3)
Parameters:
<Number> long Required Longitude value. 
<Number> lat Required Latitude value.
Sample:
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[]> point Required An input array containing the longitude and latitude values for the point. 
Sample:
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. (Added at v3.3)
Parameters:
<Object> point Required An object with latitude and longitude properties. 
Sample:
require([
  "esri/geometry/Point", ... 
], function(Point, ... ) {
  var point = new Point({
    latitude: 38,
    longitude: -98
  });
  ...
});
Property Details

<Object> cache

The cache is used to store values computed from geometries that need to cleared or recomputed upon mutation. An example is the extent of a polygon. The default value is undefined. (Added at v3.13)
Default value: undefined
Sample:
var map;

require([
  "esri/InfoTemplate",
  "esri/layers/FeatureLayer",
  "esri/map",
  "esri/tasks/query", "dojo/domReady!"
], function (InfoTemplate, FeatureLayer, Map, Query){

  map = new Map("map", {
    basemap: "topo",
    center: [-122.45, 37.75], // longitude, latitude
    zoom: 10
  });

  var infoTemplate = new InfoTemplate("Attributes", "${*}");

  var countiesFeatureLayer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/3",
    {
      mode: FeatureLayer.MODE_ONDEMAND,
      infoTemplate: infoTemplate,
      outFields: ['*']
    });
  var highwaysFeatureLayer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/1",
    {
      mode: FeatureLayer.MODE_ONDEMAND,
      infoTemplate: infoTemplate,
      outFields: ['*']
    });

  map.on("load", function (){
    map.addLayer(countiesFeatureLayer);
    map.addLayer(highwaysFeatureLayer);

    var query = new Query();
    query.geometry = map.extent;
    query.spatialRelationship = Query.SPATIAL_REL_ENVELOPEINTERSECTS;
    query.returnGeometry = true;
    query.outFields = ["*"];

    countiesFeatureLayer.queryFeatures(query, function (featureSet){
      var polygon = featureSet.features[0].geometry;
      // populate the Geometry cache by calling getExtent()
      var polygonExtent = polygon.getExtent();
      console.log("polygonExtent", polygonExtent);
      console.log("polygon.cache._extent", polygon.cache._extent);

      for (var i = 0; i < featureSet.features.length; i  ) {
        var feature = featureSet.features[i];
        console.log("Polygon geometry cache, %o", feature.geometry.cache);
        feature.geometry.clearCache();
        console.log("Polygon geometry clear cache, %o", feature.geometry.cache);
        // Break out of the loop after the first result
        break;
      }
    });

    highwaysFeatureLayer.queryFeatures(query, function (featureSet){
      var line = featureSet.features[0].geometry;
      // populate the Geometry cache by calling getExtent()
      var lineExtent = line.getExtent();
      console.log("lineExtent", lineExtent);
      console.log("line.cache._extent", line.cache._extent);

      for (var i = 0; i < featureSet.features.length; i  ) {
        var feature = featureSet.features[i];
        console.log("Line geometry cache, %o", feature.geometry.cache);
        feature.geometry.clearCache();
        console.log("Line geometry clear cache, %o", feature.geometry.cache);
        // Break out of the loop after the first result
        break;
      }
    });

  });
});

<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

clearCache()

Sets the cache property to undefined. (Added at v3.13)

getCacheValue(name)

Returns the value for a named property stored in the cache. (Added at v3.13)
Return type: Object
Parameters:
<String> name Required The property name of the value to retrieve from the cache.

getLatitude()

Returns the latitude coordinate for this point if the spatial reference of the point is Web Mercator or Geographic (4326). (Added at v3.3)
Return type: Number

getLongitude()

Returns the longitude coordinate for this point if the spatial reference of the point is Web Mercator or Geographic (4326). (Added at v3.3)
Return type: Number

normalize()

Shifts the x coordinate to within +/- 180 span. (Added at v3.8)
Return type: Point

offset(dx, dy)

Returns a new Point with x and y offsets. Units are map units.
Return type: Point
Parameters:
<Number> dx Required The offset distance in map units from the x-coordinate.
<Number> dy Required The offset distance in map units from the y-coordinate.

setCacheValue(name, value)

Sets the value for a named property stored in the cache. (Added at v3.13)
Parameters:
<String> name Required The property name for the value Object to store in the cache.
<Object> value Required The value Object for a named property to store in the cache.

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). (Added at v3.3)
Return type: Point
Parameters:
<Number> lat Required A valid 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). (Added at v3.3)
Return type: Point
Parameters:
<Number> lon Required A valid longitude value.

setSpatialReference(sr)

Sets the spatial reference.
Return type: Geometry
Parameters:
<SpatialReference> sr Required Spatial reference of the geometry.

setX(x)

Sets x-coordinate of point.
Return type: Point
Parameters:
<Number> x Required Value for x-coordinate of point.

setY(y)

Sets y-coordinate of point.
Return type: Point
Parameters:
<Number> y Required Value for y-coordinate of point.

toJson()

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

update(x, y)

Updates a point. (Added at v1.4)
Return type: Point
Parameters:
<Number> x Required X-coordinate of the updated point.
<Number> y Required Y-coordinate of the updated point.