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
Properties
Methods
Constructor Details
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 }));
...
});
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 }));
...
});
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 } });
...
});
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);
...
});
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]);
...
});
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
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-vector",
center: [-122.45, 37.75], // longitude, latitude
zoom: 9
});
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;
}
});
});
});
The type of geometry.
Known values: point
| multipoint
| polyline
| polygon
| extent
X-coordinate of a point in map units.
Y-coordinate of a point in map units.
Method Details
Sets the cache property to undefined
. (Added at v3.13)
Returns the value for a named property stored in the cache. (Added at v3.13)
Parameters:
<String > name |
Required |
The property name of the value to retrieve from the cache. |
Returns the latitude coordinate for this point if the spatial reference of the point is Web Mercator or Geographic (4326). (Added at v3.3)
Returns the longitude coordinate for this point if the spatial reference of the point is Web Mercator or Geographic (4326). (Added at v3.3)
Shifts the x coordinate to within +/- 180 span. (Added at v3.8)
Returns a new Point with x and y offsets. Units are map units.
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. |
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. |
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)
Parameters:
<Number > lat |
Required |
A valid latitude value. |
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)
Parameters:
<Number > lon |
Required |
A valid longitude value. |
Sets the spatial reference.
Sets x-coordinate of point.
Parameters:
<Number > x |
Required |
Value for x-coordinate of point. |
Sets y-coordinate of point.
Parameters:
<Number > y |
Required |
Value for y-coordinate of point. |
Updates a point. (Added at v1.4)
Parameters:
<Number > x |
Required |
X-coordinate of the updated point. |
<Number > y |
Required |
Y-coordinate of the updated point. |