Select to view content in your preferred language

buffer return fetures from all layers

1273
10
04-12-2012 10:28 AM
LefterisKoumis
Frequent Contributor
I am looking for a  modified search widget specify a line and/or line buffer on a specified distance and return the features from other layers found within the selected buffer. Is there anything out there close to this functionality? Thank you.
Tags (2)
0 Kudos
10 Replies
LefterisKoumis
Frequent Contributor
I think you are correct Mattias. Using the identifyTask will do the trick as long as you have all your layers in one service. Combine multiple services (WebmapServers, WMS, WFS) in to one identifier task would have been great. Something for 3.1?
In addition to setting your buffered line as geometry in the identifyparameters you also need to set the layeroptions to "all". Something like his:
//Executes when drawing is completed assuming you draw your line
private function drawEnd(event:DrawEvent):void
   {
    
    var geom:Geometry = event.graphic.geometry;
    identifyParameters.returnGeometry = true;
    identifyParameters.tolerance = 3;
    identifyParameters.width = map.width;
    identifyParameters.height = map.height;
    identifyParameters.layerOption = "all";
    identifyParameters.mapExtent = map.extent;
    identifyTask.showBusyCursor = true;
    
    //Bufferering drawing
    var bufferParameters:BufferParameters = new BufferParameters();
    bufferParameters.geometries = [ geom ];
    bufferParameters.distances = [ <your buffer distance value> ];
    bufferParameters.unit = GeometryService.UNIT_METER;
    bufferParameters.outSpatialReference = map.spatialReference;
    bufferParameters.unionResults = true;
     
    geometryService.addEventListener(GeometryServiceEvent.BUFFER_COMPLETE, bufferCompleteHandler1);
    geometryService.buffer(bufferParameters);
     
    function bufferCompleteHandler1(event:GeometryServiceEvent):void
    {
     for each (var polygon:Polygon in event.result)
     {
      geometryService.removeEventListener(GeometryServiceEvent.BUFFER_COMPLETE, bufferCompleteHandler1);
      identifyParameters.geometry = polygon;
      identifyTaskIntresseletaren.execute(identifyParameters)
      break;
     }
    }
   }
   
<esri:GeometryService id="geometryService" url="<your geometry service> "/>
  
<esri:IdentifyParameters id="identifyParameters"/>
  
<esri:IdentifyTask id="identifyTask"
       concurrency="last"
       showBusyCursor="true"
 executeComplete="identifyTask_executeCompleteHandler(event)"/>



This will work as long as you don't combine your spatial search with a text search.

text search - use findtask
spatial search - use identifytask
text and spatial search - use querytask but can only search on one layer and field at a time
searching in one layer only - use querytask, much faster than findtask and identifytask

Karl M
Växjö municipality


Thank you. I thought that a loop to go through all the layers are identified in an array could do just that. I will work with your code to see if that works. Thank you.
0 Kudos