AnsweredAssumed Answered

JavaScript Spatial Query for Multiple Layer Types

Question asked by shepa006 on Jan 26, 2015
Latest reply on Feb 2, 2015 by oearley

I'm contemplating how to set up my function so that it accepts a geometry (the user will be able to use the draw toolbar to create the search geometry) and will 'query' any layer in the map that is visible.

 

* All results will get written to a central graphics array so that I can put the results in a side panel, display 'selected' graphics on the map, and highlight the current attributes being viewed in the side panel.

 

* The map uses different layer types that all need to be queried at once and the results managed together: ArcGISDynamicMapServiceLayer, FeatureLayer, CSVLayer (from local user file), GraphicsLayer (build on demand from JSON string)

 

* Search geometry could be a point, line, or polygon

 

* Map layers could contain point, line, or polygon features/graphics

 

  1. Loop through all of the layers in the map to determine the type of layer
    1. Using layerIds, graphicsLayerIds, and basemapLayerIds gets me part of the way there
    2. I also test if the 'capabilities' property is present and if it supports Query or Identify
  2. If the layer ID is in layerIds and Identify is supported then create and run an IdentifyTask
  3. If the layer ID is in graphicsLayerIds and Query is supported then I'm thinking it would be a feature layer and I could use featureLayer.selectFeatures
  4. Anything else in the graphicsLayerIds I would test if graphics > 0
    1. I was considering using the relation geometry service but I've seen a lot comments that people abandoned this type of approach because of asynchronous timing issues and not being able to trace back to the original layer(s) to get the full graphic result
    2. I also considered creating 'local' feature layer, one that is built from a FeatureCollection and doesn't come from ArcGIS Server, but when you do that it doesn't seem to support the Query capability

 

Suggestions on any of this would be appreciated.

Outcomes