A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.arcgis.com/javascript/3/jsapi/polygon-amd.html below:

Polygon | API Reference | ArcGIS API for JavaScript 3.46

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

(Added at v1.0)

An array of rings where each ring is an array of points. The first and last points of a ring must be the same.

Samples

Search for

samples

that use this class.

Class hierarchy
esri/geometry/Geometry
|_esri/geometry/Polygon
Subclasses Constructors Properties Methods

Constructor Details

Creates a new Polygon object.

Sample:
require([
  "esri/geometry/Polygon", "esri/SpatialReference", ... 
], function(Polygon, SpatialReference, ... ) {
  var poly = new Polygon(new SpatialReference({wkid:4326}));
  ...
});

Creates a new Polygon object using a JSON object.

Parameters: <Object> json Required JSON object representing the geometry. Sample:
require([
  "esri/geometry/Polygon", ... 
], function(Polygon, ... ) {
  var polygonJson  = {"rings":[[[-122.63,45.52],[-122.57,45.53],[-122.52,45.50],[-122.49,45.48],
    [-122.64,45.49],[-122.63,45.52],[-122.63,45.52]]],"spatialReference":{"wkid":4326 }};
  var polygon = new Polygon(polygonJson);
  ...
});

Create a new polygon by providing an array of geographic coordinate pairs. For a single ring polygon specify an array of coordinate pairs. For a multi-ring polygon specify an array of array coordinate pairs. (Added at v3.6)

Sample:
var singleRingPolygon = new Polygon([[50, 0], [150, 20], [150, -20], [50,0]]);

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

  });
});

An array of rings. Each ring is made up of three or more points.

The type of geometry.

Known values: point | multipoint | polyline | polygon | extent

Method Details

Adds a ring to the Polygon. The ring can be one of the following: an array of numbers or an array of points. When added the index of the ring is incremented by one.

Sample:
require([
  "esri/geometry/Polygon", "esri/SpatialReference", ... 
], function(Polygon, SpatialReference, ... ) {
  var polygon = new Polygon(new SpatialReference({wkid:4326}));
  polygon.addRing([[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]);

add points counter-clockwise to create a hole

  polygon.addRing([[-83,35],[-74,35],[-74,41],[-83,41],[-83,35]]);
  ...
});

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

Checks on the client if the specified point is inside the polygon. A point on the polygon line is considered in.

Parameters: <Point> point Required The location defined by an X- and Y- coordinate in map units.

Returns a new Polygon with one ring containing points equivalent to the coordinates of the extent.

Note: This is a static method.

(Added at v3.11) Parameters: <Extent> extent Required The Extent geometry to convert to a Polygon. Sample:
  var selectionPolygon = Polygon.fromExtent(selectionExtent);

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 centroid of the polygon as defined

here

. For a polygon with multiple rings, returns the centroid of the largest ring.

Note: Polygon with holes supported as of version 3.8. (Added at v3.7)

Returns the extent of the polygon.

Sample:

var taxLotExtent = selectedTaxLot.geometry.getExtent();

Returns a point specified by a ring and point in the path.

Parameters: <Number> ringIndex Required The index of a ring. <Number> pointIndex Required The index of a point in a ring.

Inserts a new point into a polygon. (Added at v1.4)

Parameters: <Number> ringIndex Required Ring index to insert point. <Number> pointIndex Required The index of the inserted point in the ring. <Point> point Required Point to insert into the ring.

Checks if a

Polygon

ring is clockwise. Returns true for clockwise and false for counterclockwise.

Sample:
require([
  "esri/geometry/Polygon", ... 
], function(Polygon, ... ) {
  var polygon = new Polygon( ... );
  var clockwise = polygon.isClockwise(polygon.rings[0]);
  ...
});

When true, the polygon is self-intersecting which means that the ring of the polygon crosses itself. Also checks to see if polygon rings cross each other. (Added at v2.2)

Parameters: <Polygon> polygon Required The polygon to test for self-intersection. Sample:
require([
  "esri/geometry/Polygon", ... 
], function(Polygon, ... ) {
  var polygon = new Polygon( ... );
  var isIntersecting = polygon.isSelfIntersecting(polygon);
  ...
});

Remove a point from the polygon at the given pointIndex within the ring identified by ringIndex. (Added at v2.0)

Parameters: <Number> ringIndex Required The index of the ring containing the point. <Number> pointIndex Required The index of the point within the ring.

Removes a ring from the Polygon. The index specifies which ring to remove.

Parameters: <Number> ringIndex Required The index of the ring 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 a point in a polygon. (Added at v1.4)

Parameters: <Number> ringIndex Required Ring index for updated point. <Number> pointIndex Required The index of the updated point in the ring. <Point> point Required Point to update in the ring.

Sets the spatial reference.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4