DynamicMapService / layerDefinitions - Viewer for Flex 2.5 - not working

2370
4
Jump to solution
04-30-2013 11:01 AM
TimSaldana1
New Contributor II
I am unable to get the following code to work.
My map services has 14 layers, I want to apply the filter to layers 4 & 5 (zero-base).
This function is tied to the button change event function and is firing no problem; my trace statements all display correctly.
The documentation does have an extra "," at the end of the array. I have tried with and without it.
I get no requests to the server when viewing in Fiddler. Do I need to trigger that in my code? My thought was that the map object handled changes to layers.

Thanks for any advice to correct the issue.

   private function setFloorLayerDef(floor:String) : void    {        for (var i:int = 0; i < opLayers.length; i++){      trace(opLayers.label);      if (opLayers.label == "Category Codes" || opLayers.label == "Organizations")       {       trace("set Floor " + opLayers.label);       opLayers.layerDefinitions = [null, null, null, null, "Floor = '" + floor + "'", "Floor = '" + floor + "'", null, null, null, null, null, null, null, null,];       trace(opLayers.layerDefinitions);               //identifyParams.layerIds = i;       //ViewerContainer.getInstance().mapManager.map.getLayer(opLayers.label).visible = true;      }     }    }
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
SarthakDatt
Occasional Contributor III
Can you try:

   private function setFloorLayerDef(floor:String) : void
   {   
    for (var i:int = 0; i < opLayers.length; i++){
     trace(opLayers.label);
     if (opLayers.label == "Category Codes" || opLayers.label == "Organizations") 
     {
      trace("set Floor " + opLayers.label);
                                                var layer:Layer = opLayers.layer;
                                                if (layer is ArcGISDynamicMapServiceLayer)
                                                {
      ArcGISDynamicMapServiceLayer(layer).layerDefinitions = [null, null, null, null, "Floor = '" + floor + "'", "Floor = '" + floor + "'", null, null, null, null, null, null, null, null,];
                                                }
      trace(opLayers.layerDefinitions);
       
      //identifyParams.layerIds = i;
      //ViewerContainer.getInstance().mapManager.map.getLayer(opLayers.label).visible = true;
     }
    }
   }

View solution in original post

0 Kudos
4 Replies
SarthakDatt
Occasional Contributor III
Can you try:

   private function setFloorLayerDef(floor:String) : void
   {   
    for (var i:int = 0; i < opLayers.length; i++){
     trace(opLayers.label);
     if (opLayers.label == "Category Codes" || opLayers.label == "Organizations") 
     {
      trace("set Floor " + opLayers.label);
                                                var layer:Layer = opLayers.layer;
                                                if (layer is ArcGISDynamicMapServiceLayer)
                                                {
      ArcGISDynamicMapServiceLayer(layer).layerDefinitions = [null, null, null, null, "Floor = '" + floor + "'", "Floor = '" + floor + "'", null, null, null, null, null, null, null, null,];
                                                }
      trace(opLayers.layerDefinitions);
       
      //identifyParams.layerIds = i;
      //ViewerContainer.getInstance().mapManager.map.getLayer(opLayers.label).visible = true;
     }
    }
   }

0 Kudos
TimSaldana1
New Contributor II
Thanks Sarthak-

I know get an error "possibly undefined property ArcGISDynamicMapServiceLayer".

import com.esri.ags.layers.DynamicMapServiceLayer;
   import com.esri.ags.layers;


I have these defined. How do I get a refernce to that class?
0 Kudos
SarthakDatt
Occasional Contributor III
You need to add:
import com.esri.ags.layers.ArcGISDynamicMapServiceLayer;


If you are using an IDE(e.g Flash Builder), you can use short-cuts to automatically add the import statements. In this case Ctrl+Spacebar would help in code-assist(will show a menu, picking from the menu would add the corresponding import statement)

You can refer to: http://www.adobe.com/devnet/flex/articles/flashbuilder_shortcuts_tips.html for details.
0 Kudos
TimSaldana1
New Contributor II
Thank you Sarthak-

That fixed it. I will definitely check out the FB tips page.
0 Kudos