2

I'm using the following code in Flex to display all the features in a Feature Class defined in the "Data Layer".

var dataLayer:ArcGISDynamicMapServiceLayer= map.getLayer("Data Layers") as ArcGISDynamicMapServiceLayer;
var dataLayerId:int;

dataLayerId = 5;

dataLayer.visibleLayers.removeAll();
dataLayer.visibleLayers.addItem(dataLayerId);
dataLayer.refresh();

But I'd like to apply a filter like "WHERE MGD = 1" (MGD is an attribute defined in the feature class) to display only a subset of that feature class. Any help or autosuggestion would be much appreciated.

2

Thanks to Sunil's comments, the following is the right code to answer my question:

            var dataLayer:ArcGISDynamicMapServiceLayer= map.getLayer("Data Layers") as ArcGISDynamicMapServiceLayer;
            var dataLayerId:int;
            var layerDefs:Array = new Array();

            dataLayerId = 5;

            dataLayer.visibleLayers.removeAll();
            dataLayer.visibleLayers.addItem(dataLayerId);
            layerDefs = [];
            layerDefs[dataLayerId] = " MGD = 1 " 
            dataLayer.layerDefinitions = layerDefs; 
            dataLayer.refresh();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.