Select to view content in your preferred language

IdentifyTask.Execute not working when selecting from a Buffered Graphic Geometry.

937
6
Jump to solution
03-13-2012 09:17 AM
by Anonymous User
Not applicable
I have gotten the geometry service to select a buffer on my map.  Although, within the buffer I can???t identify anything.  I am using the IdentifyTask object to perform this operation.  Within the IdentifyTask I am passing the IdentifyParameters object to the IdentifyTask.execute and using the AsyncResponder to handle the results of the execute.  Nothing is happening when I hit the IdentifyTask.execute it is not completing or faulting.  It is not identifying any features on the map.  Do you have any ideas on why the execute is not working?  Any help would be much appreciated.

here is a snippet of the code that I am using.  I have verified that all the map service and layer index from the XML file is correct.

                        private function activateIdentifyTool(type:String):void    {     var status:String = "Buffer";          if(type == 'point')     {      setMapAction(DrawTool.MAPPOINT, status, sms, drawEnd);           }    }         private var bufferGraphic:Graphic;     private function drawEnd(event:DrawEvent):void    {     clear();     var i:int = 0;     var hg:HGroup;     var ch:spark.components.CheckBox;     var id:Number;     selectedLyrArray = [];          for(i =0; i < vb1.numChildren;i++)     {      hg = vb1.getElementAt(i) as HGroup;      ch = hg.getElementAt(0) as spark.components.CheckBox;      if (ch.selected == true)      {       id = Number(ch.id);       selectedLyrArray.push(id);      }     }          for(i =0; i < vb2.numChildren;i++)     {      hg = vb1.getElementAt(i) as HGroup;      ch = hg.getElementAt(0) as spark.components.CheckBox;      if (ch.selected == true)      {       id = Number(ch.id);       selectedLyrArray.push(id);      }     }          if (selectedLyrArray.length == 0)     {      Alert.show("No Layers Are Selected");     }     else     {      var geom:Geometry = event.graphic.geometry;      var g:Graphic = new Graphic(geom, sms);      graphicsLayer.add(g);                        var bp:BufferParameters = new BufferParameters();      bp.geometries = [g.geometry];       bp.distances = [ns.value];            if (cboUnits.selectedIndex == 1)      {       bp.unit = GeometryService.UNIT_FOOT;      }      else      {       bp.unit = GeometryService.UNIT_STATUTE_MILE;      }      //bp.bufferSpatialReference = new SpatialReference(102100);            geometryService.addEventListener(GeometryServiceEvent.BUFFER_COMPLETE, onBufferComplete);      geometryService.buffer(bp);           function onBufferComplete(event:GeometryServiceEvent):void      {       bufferGraphicsLayer.clear();       bufferGraphic = new Graphic;       //In this version of esri the geometryService returns geometries instead of graphics.       bufferGraphic.geometry = event.result[0] as Polygon;       var sls:SimpleLineSymbol = new SimpleLineSymbol("dash",0xff0000,.8,2);       var sfs:SimpleFillSymbol = new SimpleFillSymbol("solid",0xff0000,.2,sls);       bufferGraphic.symbol = sfs;              var attribs:Object =       {         distance: ns.value,         unit: bp.unit       }              bufferGraphic.attributes = attribs;       bufferGraphicsLayer.add(bufferGraphic);       startIdentify();      }        }    }                        private function startIdentify():void    {          showMessage("Processing Results...",true);     showStateResults();     selectionGraphicsAC = new ArrayCollection();     identifyArrayCollection = new ArrayCollection();     identifycounter = 0;         identifyTask = new IdentifyTask(lyrList[selectedLyrArray[identifycounter]].@mapservice);     identifyParams = new IdentifyParameters();     identifyParams.returnGeometry = true;     identifyParams.tolerance = 1;     identifyParams.width = map.width;     identifyParams.height = map.height;     identifyParams.mapExtent = map.extent;     identifyParams.geometry = bufferGraphic.geometry;     identifyParams.layerIds = [lyrList[selectedLyrArray[identifycounter]].@layerIndex];     identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;     identifyParams.spatialReference = map.spatialReference;     identifyTask.execute(identifyParams, new AsyncResponder(identifyCompleteHandler,myFaultFunction));          }                    private function myFaultFunction(error:Object):void    {     Alert.show(String(error), "Identify Error");    }        private function identifyCompleteHandler(results:Array):void    {     Alert.show("I am here in identifyCompleteHandler");     identifycounter++;     processIdentifyResults(results, identifycounter-1);    }
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
6 Replies
by Anonymous User
Not applicable
I did receive the correct results back from the server when executing the buffer identify in the network monitor.  So real issue is that the callback is not executing!!  Any help would be appreciated.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ray,

   Have you debugged your code at all, and checked to see if the polygon buffer is getting populated and has the same spatial reference as the data you are attempting to identify? Have you tried not specifying identifyParams.layerIds?
0 Kudos
by Anonymous User
Not applicable
Robert,
Thanks, for the reply... I got the event listener working.  I was passing the wrong argument type into the parameter list of the handler. I was passing it an array type when it should have been an IdentifyEvent type.  Once I made that change it worked fine despite some other small issues.  Robert, can you recommend some debugging tools for flex.  I am using Flash builder 4.5 and it has no where near the debugging capabilities as visual studio.  Thanks you for the help.

Ray
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ray,

   All the debugging capability you should need is there you just have to have the Flash Player Debugger installed to use it.

Go to this link and choose the IE or Netscape compatible version of the Flash Player Debugger to download and install it. then if you normally pressed the green play button to test in flash player you will now use the little green bug button instead.

Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
by Anonymous User
Not applicable
Robert,

What link was that again??
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ray,

   :rolleyes: Forgot to paste the link:

http://www.adobe.com/support/flashplayer/downloads.html
0 Kudos