Select to view content in your preferred language

Adding multiple geometries of different types - Polygon and multipolygon on the map

577
3
02-14-2024 01:52 AM
DivyaArora
Emerging Contributor

I am trying to add multiple geometries of different types - polygon and multipolygon on  the map. For this I have used Graphicslayer.

While creating the graphic object I am using "polygon" as the Geomtery type for POLYGON geometry but if we have a MULTIPOLYGON geometry, then what type should i pass in the geometrytype ?

Refering the Geometry , it does not give any option for Multupolygon

 

DivyaArora_0-1707904322527.png

0 Kudos
3 Replies
jauhari_mani
Regular Contributor

Hi @DivyaArora ,

You can consume GeoJSON layer in case of MultiPolygon Geometry as mentioned in their documentation.

GeoJSONLayer | API Reference | ArcGIS Maps SDK for JavaScript 4.28 | ArcGIS Developers

There is no explicit mention of MultiPolygon in case of graphic layer.

0 Kudos
DivyaArora
Emerging Contributor

Geojson layer accepts only single type of geometry.

DivyaArora_0-1707906522059.png

 

0 Kudos
EmilyGoldsmith
Occasional Contributor

Could you use the .push() function to add new graphics into one, main GraphicsLayer?

Example here: https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#push

// Adds a new graphic to the end of the graphics collection on a GraphicsLayer
graphicsLyr.graphics.push(newGraphic);

// Adds three new graphics to the end of the GraphicsLayer's graphics collection
graphicsLyr.graphics.push(g1, g2, g3);
0 Kudos