I am trying to project an array of points from UTM to 102100 but no luck. [HTML]
var wellGraphics:Array = []; for each (var item:Object in wellResults){ var attrib:Object = { Permit_id:item.pid, Resp_party:item.resParty, County:item.county } if(item.Datum == 27){ var datum:Number = 26717; }else{ datum = 26917; } var wPoint:MapPoint = new MapPoint(item.UTME,item.UTMN,new SpatialReference(datum)); var wgraphics:Graphic = new Graphic(wPoint,null,attrib); wellGraphics.push(wgraphics); } var outSR:SpatialReference = new SpatialReference(102100); geometryService.project(wellGraphics,outSR); } protected function projectCompleteHandler(event:GeometryServiceEvent):void { trace(event.result); }
The GeometryService in the 2.0 API does not take graphics anymore it takes an array of geometries now.
Thanks Robert, Yelp. You are right. I have found a work around but i am not happy with it. I want to re project bunch of points at once, not one by one...
The GeometryService in the 2.0 API does not take graphics anymore it takes an array of geometries now.
The other work arround to do a batch type process is as under but now i am loosing all the attributes.. [HTML] var wPoint:MapPoint = new MapPoint(item.UTME,item.UTMN,new SpatialReference(datum)); var wgraphics:Graphic = new Graphic(wPoint,null,attrib); wellGraphics.push(wPoint); } geometryService.project(wellGraphics,new SpatialReference(102100)); } protected function projectCompleteHandler(event:GeometryServiceEvent):void { var pntArray:Array = event.result as Array; var sp:SpatialReference = new SpatialReference(102100); for each(var item:Object in pntArray){ var pt:MapPoint = new MapPoint(item.x,item.y, sp); var g:Graphic = new Graphic (pt); graphicsLayer.add(g); } [/HTML]
Either way it is not very good coding...there has to be a better way
If I remember correctly the results of the project method return the geometry array in the exact same order so you can just loop back through your attributes and attach them to the results.