Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
1  
According to the description I think you need to use Layer Definitions example (help.arcgis.com/en/webAPI/flex/samples/index.html#/…) I assume that you are applying filer to dynamic layer..thanks.. –  Sunil Feb 12 '13 at 5:27
    
+ you are using sql server tag so are you using query layer ? if yes then you can insert the filter in query itself (example help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/…) –  Sunil Feb 12 '13 at 5:30

1 Answer 1

up vote 2 down vote accepted

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();
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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