ccgage

How to get startTime for each layer in a time enabled service

Discussion created by ccgage on Nov 27, 2012
I am trying to see if it is possible to get the startTime for each layer in a time enabled service.  What I am doing is very similar to the Sample Time Slider with Dynamic map Service, but with one minor addition.  Where the sample sets a hardcoded startTime, I want to get it from a specific layer in the service.

I have added the following code to the sample as follows:
        var timeExtent = new esri.TimeExtent();
timeExtent.startTime = results[2].layer.timeInfo.timeExtent.startTime;

The "results" array is passed into the function initSlider(results).

This code works but it always gets the startTime of the first array item of results and not the item that I am asking for (ex. results[2]).  I am not a JavaScript expert at all, so I was wondering if someone knows of a way to get at a particular array item of results?

Thanks,
Charlie

Outcomes