Select to view content in your preferred language

Edit an existing geometry on map

2892
13
Jump to solution
11-11-2022 05:23 AM
DivyaArora
Emerging Contributor

We are trying to integrate the ESRI Maps in a React Application. Using  ARCGIS API for JS 4.24, we are able to draw the map and add features like marker and boundary on the map.

Now, we need  to edit the geometry on the map by performing various operations like draw polygon, circle, split, move , delete etc. We could not find anything in the ARCGIS API for JS 4.24.

The document has some examples for ARCGIS API for JS 3.42 but in this case we are not able to render the map.

Using the code like below , we are getting the error : "Module not found: Error: Can't resolve 'esri/Map'"

import Map from "esri/Map";
 
 map = new Map("map", {
            basemap: "streets-vector",
            center: [-15.469, 36.428],
            zoom: 3
          });
 
Any help regarding implementing the feature would be appreciated
0 Kudos
13 Replies
JayakumarPD
Frequent Contributor

Good. It got resolved. 

You can see the knowledge content from Sri. Rene Rubalcava, on geometry engine recently sir published a video on yotube. 

Keep on Mapping...

https://www.youtube.com/@odoenet   

DivyaArora
Emerging Contributor

Hi @JayakumarPD 

I will try to rephrase my requirement. For ex : I have 2 polygons initially and i need to split them into 4 using a polyline(cutter).

Query : How can i pass these 2 polygons to get the new splitted polygon's geometry because as per the documentation, the cut method accepts a single geometry.

 const geometries = geometryEngine.cut(polygon1, line1);
// here i can pass only single polygon

 

The concern is to split multiple polygons into another set of multiple polygons.

0 Kudos
DivyaArora
Emerging Contributor

Anyone could help me in this please

0 Kudos
JayakumarPD
Frequent Contributor

You can iterate over polygon and apply the cut geometry

 if (isCrossed) {
              rings1.map((x) => {
                const iteratingGeometry = new Polygon({
                  rings: x,
                  hasZ: false,
                  hasM: false,
                  spatialReference: { wkid: 102100 },
                });
               
                const geometries = geometryEngine.cut(iteratingGeometry, line1);
                console.log(geometries);

Will it be helpful

0 Kudos