Select to view content in your preferred language

How to draw polygons using geometry through code

576
0
03-23-2011 11:21 PM
MuneebAbdul_Shakoor
New Contributor
I have a scenario where users can store spatial requests generated by ArcGIS map when user draws shapes. The format I save is like,

{ "geometry": "{\"rings\":[[[2405243.85460683,2198119.53579023],[2392094.38090583,2180418.32119274],[2389565.63596333,2205200.02162924],[2405243.85460683,2198119.53579023]]],\"spatialReference\":{\"wkid\":<id>}}", "geometryType": "esriGeometryPolygon" }

Now using this JSON, I want user to reload the polygon on the map.

I tried writing code,

var arrSavedGraphics:Array = new Array();

var objGeom:Object = JSON.decode(objJson.geometry);

var poly:Polygon = new Polygon();
poly.rings = objGeom.rings;
arrSavedGraphics.push(new Graphic(poly, shpSymbol));
}

myLoadGraphicsLayer.graphicProvider = new ArrayCollection(arrSavedGraphics);

where,
objJson reporesent the JSON that I posted above
shpSymbol: <shp:ShpSymbol id="shpSymbol"/>
myLoadGraphicsLayer: var myLoadGraphicsLayer:GraphicsLayer = new GraphicsLayer;


I dont get any error but the shapes are not re drawn. So anyone here can tell me where I am wrong or if some alternate solution is there please tell

Thanks in advance.

Regards,
Muneeb Abdul Shakoor
Tags (2)
0 Kudos
0 Replies