I am developing with the ArcGIS JavaScript web API and ArcGIS server 10.0.
I have a time-aware layer in in my map, and also a timeslider. The full time extent of the map is a year, with data every month.
I want that when the map loads, the data is shown for that particular month, and the slider is also on that month.
I can programatically set the timeExtent on the map, using map.setTimeExtent()
, but the timeslider does not auto-update to this date.
How should the timeExtent to be set, so that the timeSlider auto-updates along with it?
To see an reproducible example, go to the sample: http://help.arcgis.com/en/webapi/javascript/arcgis/samples/time_sliderwithdynamiclayer/index.html, and open up your firebug/developer console, and enter
map.setTimeExtent(map.timeSlider.fullTimeExtent);
The map will show you data for the entire period, but the time slider does not update.
Best Answer
You are approaching this backwards--the time slider's time extent updates the map's time extent, not the other way around. It's my understanding that the map.setTimeExtent() function should only be called when a time slider is not in use.
You should be setting the extent of the time slider and setting the position of the time thumb(s), which then updates the current time extent of the map.
If you have already configured your time slider, this is as simple as:
This will move the time slider's thumb position to the first time stop, which will then update the map's time extent to match. Any time-enabled layers will be listening for this event and will redraw automatically.
If you have two time thumbs, you have to set the index of each one:
Here is a more complete example, assuming you have data valid on the first day of each month:
If you already have a time slider and need to reset its time extent: