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

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

NameSummary
new Multipoint(spatialReference)Creates a new Multipoint object.
new Multipoint(json)Creates a new Multipoint object using a JSON object.

Properties

NameTypeSummary
cacheObjectThe cache is used to store values computed from geometries that need to cleared or recomputed upon mutation.
pointsNumber[][]An array of one or more points.
spatialReferenceSpatialReferenceThe spatial reference of the geometry.
typeStringThe type of geometry.

Methods

NameReturn typeSummary
addPoint(point)MultipointAdds a point to the Multipoint.
clearCache()NoneSets the cache property to undefined.
getCacheValue(name)ObjectReturns the value for a named property stored in the cache.
getExtent()ExtentGets the extent of all the points.
getPoint(index)PointReturns the point at the specified index.
removePoint(index)PointRemoves a point from the Multipoint.
setCacheValue(name, value)NoneSets the value for a named property stored in the cache.
setPoint(index, point)MultipointUpdates the point at the specified index.
setSpatialReference(sr)GeometrySets the spatial reference.
toJson()ObjectConverts object to its ArcGIS Server JSON representation.
Constructor Details

new Multipoint(spatialReference)

Creates a new Multipoint object.
Parameters:
<SpatialReference> spatialReference Required Spatial reference of the geometry.
Sample:
require([
  "esri/geometry/Multipoint", "esri/SpatialReference", ... 
], function(Multipoint, SpatialReference, ... ) {
  var multiPoint = new Multipoint(new SpatialReference({ wkid:4326 }));
  ...
});

new Multipoint(json)

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

<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;
      }
    });

  });
});

<Number[][]> points

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]];
  ...
});
See also: addPoint()

<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
Method Details

addPoint(point)

Adds a point to the Multipoint. The point can be one of the following: an Esri Point, a number array, or a JSON object.
Return type: Multipoint
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 });
  ...
});
See also: points

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.

getExtent()

Gets the extent of all the points. If only one point is present, the extent has a width and height of 0.
Return type: Extent

getPoint(index)

Returns the point at the specified index. (Added at v2.0)
Return type: Point
Parameters:
<Number> index Required Positional index of the point in the points property.

removePoint(index)

Removes a point from the Multipoint. The index specifies which point to remove.
Return type: Point
Parameters:
<Number> index Required The index of the point to remove.

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.

setPoint(index, point)

Updates the point at the specified index. (Added at v2.0)
Return type: Multipoint
Parameters:
<Number> index Required Positional index of the point in the points property.
<Point> point Required Point that specifies the new location.

setSpatialReference(sr)

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

toJson()

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