Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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
up vote 5 down vote accepted

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

share|improve this answer
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 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.