I am creating a select features tool. It will work as follows:
- The user draws a polygon
- The draw-end event fires a function that runs an identifyTask to query the visible layers (NB. the identifyTask does NOT return the geometry).
- The callback function from the identifyTask loops through the results set and creates four arrays - a list of the layers, a list of the ids, a list of the geometry types and a corresponding set of HTML tables detailing the feature attributes for that layer
- The first array is used to create a drop-down list of layers, and when the selection changes, the display changes to display the relevant table.
So far so straightforward.
I also want the selected features to be highlighted when the layer selection is changed. To achieve this I have:
- Created a featureLayer (using the id from the array) with the mode set as MODE_SELECTION
- Set the selection symbol (uses the geometry type array to determine what type of symbol this should be)
- Created a queryTask using the geometry of the polygon created in the first step
- Run the selectFeatures method on the featureLayer using the queryTask
- Added the featureLayer to the map.
However, only the first feature in each layer is highlighted. Yet if I look at the query results in the browser console I can see multiple results are returned.
What am I missing?
Thanks,
Sarah Noakes
Cornwall Council