4

I want to be able to loop through the layers in my map, and return the names of layers that are time-enabled.

I understand that I will need to check TimeInfo and this could be enabled on a dynamic, feature or Image service within the map.

I am looking for the tidiest way of doing this, in its own function that can be called and a name of a layer returned. I have been messing about with some If statements within a 'for each' loop, but I keep struggling and making it more complicated than it needs to be.

Any advice/pointers/snippets on how to code this up in Flex would be appreciated.

  • 1
    I would be concerned about that assumption (each map has only one time-enabled layer) unless you have very strict control over the map contents. – user3461 Sep 11 '11 at 15:40
  • Bonus points for catching multiple layers, but yes - a limitation of my tool will be that it will only assume one layer is time enabled from the map. – Simon Sep 11 '11 at 23:33
5
+25

Not your full answer, but a starting point:

var timeInfo:TimeInfo;

if (layer is ArcGISDynamicMapServiceLayer)
{
    timeInfo = (layer as ArcGISDynamicMapServiceLayer).timeInfo;
}
else if (layer is ArcGISImageServiceLayer)
{
    timeInfo = (layer as ArcGISImageServiceLayer).timeInfo;
}
else if (layer is FeatureLayer)
{
    var feaLayer:FeatureLayer = layer as FeatureLayer;
    if (feaLayer.layerDetails)
    {
        timeInfo = feaLayer.layerDetails.timeInfo;
    }
}

// straight from the TimeWidget of the ArcGIS Viewer for Flex

  • Hi Bjorn - I have been basing a lot of my code on the time widget. I will see if I can tweak this section code to put it into a ForEach loop to check each layer. – Simon Sep 19 '11 at 21:09

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.