require(["esri/geometry/Multipoint"], function(Multipoint) { /* code goes here */ });
Description
(Added at v1.0)
An ordered collection of points.
Samples
Search for
samples that use this class.
Class hierarchy
esri/geometry/Geometry
|_esri/geometry/Multipoint
Constructors
Properties
Methods
Constructor Details
Creates a new Multipoint object.
Sample:
require([
"esri/geometry/Multipoint", "esri/SpatialReference", ...
], function(Multipoint, SpatialReference, ... ) {
var multiPoint = new Multipoint(new SpatialReference({ wkid:4326 }));
...
});
Creates a new Multipoint object using a JSON object.
Parameters:
<Object > json |
Required |
JSON object representing the geometry. |
Sample:
require([
"esri/geometry/Multipoint", ...
], function(Multipoint, ... ) {
var mpJson ={"points":[[-122.63,45.51],[-122.56,45.51],[-122.56,45.55]],"spatialReference":({" wkid":4326 })};
var multipoint = new Multipoint(mpJson);
...
});
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",
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;
}
});
});
});
An array of one or more points.
Sample:
require([
"esri/geometry/Multipoint", "esri/SpatialReference", ...
], function(Multipoint, SpatialReference, ... ) {
var mp = new Multipoint(new SpatialReference({wkid:4326}));
mp.points = [[-122.63,45.51],[-122.56,45.51],[-122.56,45.55],[-122.62,45.],[-122.59,45.53]];
...
});
The type of geometry.
Known values: point
| multipoint
| polyline
| polygon
| extent
Method Details
Adds a point to the Multipoint. The point can be one of the following: an Esri Point, a number array, or a JSON object.
Parameters:
<Point | Number[] > point |
Required |
The point to add. The point is either an Point or an array of numbers representing the x,y coordinates. |
Sample: Point example:
require([
"esri/geometry/Multipoint", "esri/SpatialReference", "esri/geometry/Point", ...
], function(Multipoint, SpatialReference, Point, ... ) {
var multipoint = new Multipoint(new SpatialReference{ ... });
multipoint.addPoint(new Point(-122.63,45.51));
...
});
JSON example:
require([
"esri/geometry/Multipoint", ...
], function(Multipoint, ... ) {
multipoint.addPoint({"x": -122.65, "y": 45.53 });
...
});
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. |
Gets the extent of all the points. If only one point is present, the extent has a width and height of 0.
Returns the point at the specified index. (Added at v2.0)
Parameters:
<Number > index |
Required |
Positional index of the point in the points property. |
Removes a point from the Multipoint. The index specifies which point to remove.
Parameters:
<Number > index |
Required |
The index of the point to remove. |
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. |
Updates the point at the specified index. (Added at v2.0)
Parameters:
<Number > index |
Required |
Positional index of the point in the points property. |
<Point > point |
Required |
Point that specifies the new location. |
Sets the spatial reference.