AnsweredAssumed Answered

Time aware layer and time slider

Question asked by alex92190 on Jul 2, 2014
Latest reply on May 9, 2016 by Me2
[ATTACH=CONFIG]35042[/ATTACH]Hi everyone,

I am trying to implement a time slider to my script and get an error

ReferenceError: results is not defined
 

timeExtent = results[0].layer.timeInfo.timeExtent;



Here is my code

dynaLayer1 = new ArcGISDynamicMapServiceLayer("http://webgisdevint1/arcgis/rest/services/Alex_Try/TimeawareAcres/MapServer", {});
   
   map.on("layers-add-result", initSlider);
   
   function initSlider(reults) {
          var timeSlider = new TimeSlider({
            style: "width: 100%;"
          }, dom.byId("timeSliderDiv"));
          map.setTimeSlider(timeSlider);
    var timeExtent = new TimeExtent();
          timeSlider.setThumbCount(1);
    timeExtent = results[0].layer.timeInfo.timeExtent;
          timeSlider.createTimeStopsByTimeInterval(timeExtent, 1, "esriTimeUnitsDays");
          timeSlider.setThumbMovingRate(2000);
          timeSlider.singleThumbAsTimeInstant(true);
          timeSlider.startup();
    connect.connect(timeSlider, "onTimeExtentChange", function(timeExtent) {
          dom.byId("details").innerHTML = dojo.string.substitute("${endTime}", timeExtent, function(val) {
            return dojo.date.locale.format(val, {
              selector: 'date',
              datePattern: 'MMMM yyyy'
              });
            });
           });
         }  
   
         map.on('layers-add-result', function (evt) {
            var layerInfo = arrayUtils.map(evt.layers, function (layer, index) {
            return {layer:layer.layer, title:layer.layer.name};
   });
          if (layerInfo.length > 0) {
          var legendDijit = new Legend({
            map: map,
            layerInfos: layerInfo
          }, "legendDiv");
          legendDijit.startup();
        }
      });
         map.addLayers([dynaLayer1]);


CSS:


<div class="timeWindow">
          <div id="timeSliderWin" class="shadow">
            <div id="title">
              Surface of the World
            </div>
            <div id="subTitle">
              Month by Month
            </div>
            <div id="details">
              December 2003
            </div>
            <div id="timeSliderDiv" style="width:100%;height:100%;">
            </div>
          </div>
        </div>

I am not sure why it is not working...

Attachments

Outcomes