How to measure areas and lengths of geometry drawn on sketchlayer?

Discussion created by anoopmohandas on Aug 2, 2011
Latest reply on Aug 10, 2011 by anoopmohandas
Hi all,

I'm new to ArcGis SDK, lately I have been trying to find the x-y coordinate, length and area of AGSPoint, AGSPolyline and AGSPolygon drawn on a sketchlayer.

The steps I did
1. Created an instance of AGSGeometryTaskService, initialized with server and set delegate.
2. Extraced the AGSGeometry information from sketchlayer.geometry.
3. Created an instance of AGSAreasAndLengthsParameters, set the units, assigned an array of Geometry objects and passed these parameters to areasAndLengthsWithParameters
4. The response obtained was not in the units specified in the parameters.

self.gst = [[[AGSGeometryServiceTask alloc]initWithURL:[NSURL URLWithString:kGeometryServerURL]]autorelease];
    self.gst.delegate = self;
    AGSGeometry* sketchGeometry = [[_sketchLayer.geometry copy] autorelease];
    AGSAreasAndLengthsParameters *areaAndLengthParams = [[AGSAreasAndLengthsParameters alloc]init];
    areaAndLengthParams.areaUnit = AGSAreaUnitsSquareMeters;
    areaAndLengthParams.lengthUnit = AGSSRUnitMeter;
    areaAndLengthParams.polygons = [NSArray arrayWithObject:sketchGeometry];
    [self.gst areasAndLengthsWithParameters:areaAndLengthParams];
    [areaAndLengthParams release];

Any information on where I'm doing wrong is much appreciated .