arcgis api MultiPolygon
时间: 2024-06-11 22:05:06 浏览: 77
The ArcGIS API for JavaScript supports MultiPolygon geometries, which are a collection of Polygon geometries that represent a single contiguous area.
To create a MultiPolygon geometry, you can use the `esri/geometry/MultiPolygon` module and pass in an array of Polygon geometries. Here's an example:
```javascript
require([
"esri/geometry/MultiPolygon",
"esri/geometry/Polygon",
], function(MultiPolygon, Polygon) {
// Create two Polygon geometries
const polygon1 = new Polygon({
rings: [
[
[-118.245, 34.057],
[-118.245, 34.061],
[-118.238, 34.061],
[-118.238, 34.057],
[-118.245, 34.057]
]
]
});
const polygon2 = new Polygon({
rings: [
[
[-118.238, 34.057],
[-118.238, 34.061],
[-118.232, 34.061],
[-118.232, 34.057],
[-118.238, 34.057]
]
]
});
// Create a MultiPolygon geometry from the two Polygon geometries
const multiPolygon = new MultiPolygon({
polygons: [polygon1, polygon2]
});
console.log(multiPolygon); // MultiPolygon { ... }
});
```
In this example, we create two Polygon geometries and then create a MultiPolygon geometry from them using the `esri/geometry/MultiPolygon` module. We pass in an array of the two Polygon geometries to the `polygons` property of the MultiPolygon constructor. Finally, we log the MultiPolygon geometry to the console.
Note that MultiPolygon geometries can be used in the same way as Polygon geometries, for example by adding them to feature layers or using them in spatial analysis.
阅读全文