Hello,
I am new to using ArcGIS API, I need your help. someone can help me, I'm doing a project where the user draws a polygon and need to capture the coordinates of the polygon drawn.
I am leading this example
https://developers.arcgis.com/javascript/3/jssamples/util_label_point.html
Thank you...
Solved! Go to Solution.
I think here u can get them: function addToMap(evtObj) { map.graphics.clear(); var geometry = evtObj.geometry; // add the drawn graphic to the map var symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 0]), 2), new Color([0, 0, 255, 0.5])); var graphic = new Graphic(geometry, symbol);
// u will have the geometry itself so u can get the coords for the polygon drawn but u need to use a for loop to get them all. console.log(geometry.rings); //<-- array of coords.
map.graphics.add(graphic); // simplify polygon so it can be used in the get label points request geometryService.simplify([geometry], getLabelPoints); }
I think here u can get them: function addToMap(evtObj) { map.graphics.clear(); var geometry = evtObj.geometry; // add the drawn graphic to the map var symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 0]), 2), new Color([0, 0, 255, 0.5])); var graphic = new Graphic(geometry, symbol);
// u will have the geometry itself so u can get the coords for the polygon drawn but u need to use a for loop to get them all. console.log(geometry.rings); //<-- array of coords.
map.graphics.add(graphic); // simplify polygon so it can be used in the get label points request geometryService.simplify([geometry], getLabelPoints); }
Thank you very much, I'll try.