featureLayer timeExtent doesn't match timeExtent from service description???

1067
9
Jump to solution
01-18-2013 02:59 PM
DerekMiller
New Contributor III
Hello All,

I'm putting together a map that incorporates two time enabled featurelayers with a timeSlider. Problem is, the timeExtent of the featurelayer is 1 year less than it should be, i.e. the layer.timeInfo.timeExtent.endTime of the featureLayer is returning a value of 2011, when in reality it is 2012 (the map service description confirms the timeExtent end time to be 2012).

So, the url to the MapServer to confirm the timeExtent of the service: http://cgisagsec2.portlandoregon.gov/arcgis/rest/services/BPS/solar_pdx/MapServer/0

And the code:

featurelayers are defined and pushed into an empty Array. The layers array is added to the map firing the timeSlider function (keep in mind these are snippets):

var timeLayers = []; dojo.connect(map, "onLayersAddResult", initSlider); timeLayers.push(resSolar); timeLayers.push(comSolar); map.addLayers(timeLayers);
//function to initialize the time slider     function initSlider (results) {       var timeLayers = dojo.map(results, function (result) {         return result.layer;       });       var timeExtent = new esri.TimeExtent();       timeExtent.startTime = new Date("1/1/2001 UTC");       timeExtent.endTime = new Date("1/31/2012 UTC");       map.setTimeExtent(timeExtent);       var timeSlider = new esri.dijit.TimeSlider({}, dojo.byId("timeSlider"));       map.setTimeSlider(timeSlider);       timeSlider.setThumbCount(1);       timeSlider.createTimeStopsByCount(timeExtent, 12);       timeSlider.setThumbMovingRate(1000);       timeSlider.setLoop(false);       timeSlider.startup();                //add ticks just at beginning and end       var labels = ['2001','2012'];       timeSlider.setLabels(labels);       dojo.connect(timeSlider, "onTimeExtentChange", function() {         var end = results[0].layer.timeInfo.timeExtent.endTime;         console.log(end);       });     }


The slider functions properly with the exception of the final 'tick'. The final tick sets the map.timeExtent to 1/1/2001 - 1/31/2012. The data ends at 1/1/2012, but yet none of the 2012 records display????

You may view the map and console logs at this url: http://www.portlandbps.com/gis/solar/index3.html

I'm at a loss, and I appreciate any help.

Cheers.

- d
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
Hi Derek,

When you work with feature layers in snapshot mode you get all the features on the client as graphics and the time slider queries for those features without making requests to the server. The problem, as you noted, is that if the max limit is 1000 then you may not get some of the results you suspect because you don't have all the data.
If you modify the sample to add the feature layer in on demand mode you'll see that you do see the results for 2012 but we don't recommend using the Time Slider with Feature Layer's in  on demand mode because it can result in too many requests to the server. If your service that has the max record limit upped to 2000 performs well then use that. If it doesn't then look at using an ArcGISDynamicMapServiceLayer.

View solution in original post

0 Kudos
9 Replies
DerekMiller
New Contributor III
Update:

I think it has something to do with the max feature count returned by the service. I'm curious if anyone can verify this. I'm assuming that the timeExtent from the service definition is the timeExtent of the entire dataset, while the timeExtent of the featureLayer is the timeExtent of the maximum number of records (default is 1000) returned by AGS?

Anyone have any thoughts?

Cheers.
0 Kudos
KellyHutchins
Esri Frequent Contributor
I ran a quick test based on one of the samples and can't repro the issue. In my test code (see below) features with a date of 1/1/2012 are displaying for the last set of tics.

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9">
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples 
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Demo</title>
    
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/dojo/dijit/themes/claro/claro.css">  
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css">

    <script>var dojoConfig = { parseOnLoad: true }; </script>
    <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/"></script>
    <script language="Javascript">
      dojo.require("esri.map");
      dojo.require("esri.dijit.TimeSlider");
      dojo.require("esri.layers.FeatureLayer");

      var map;

      function init() {
        var startExtent = new esri.geometry.Extent({"xmin":-13740877.445278011,"ymin":5653763.518179012,"xmax":-13588003.3887076,"ymax":5745487.95212126,"spatialReference":{"wkid":102100}});
        map = new esri.Map("map", {
          basemap: "streets",
          extent: startExtent
        });
        
        var infoTemplate = new esri.InfoTemplate("Attributes", "${*}");
        var fl = new esri.layers.FeatureLayer("http://cgisagsec2.portlandoregon.gov/arcgis/rest/services/BPS/solar_pdx/MapServer/0",{
            mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
            infoTemplate: infoTemplate
        });
        map.addLayers([fl]);
        dojo.connect(map, "onLayersAddResult", initSlider);
      }

      function initSlider() {

        var timeSlider = new esri.dijit.TimeSlider({
          style: "width: 1000px;"
        }, dojo.byId("timeSliderDiv"));
        map.setTimeSlider(timeSlider);
        
        var timeExtent = new esri.TimeExtent();
        timeExtent.startTime = new Date("1/1/2009 UTC");
        timeExtent.endTime = new Date("1/31/2012 UTC");
        timeSlider.setThumbCount(2);
        timeSlider.createTimeStopsByTimeInterval(timeExtent,1,'esriTimeUnitsMonths');
        timeSlider.setThumbIndexes([0,1]);
        timeSlider.setThumbMovingRate(2000);
        timeSlider.startup();
        
      }
      dojo.ready(init);
    </script>
  </head>
  <body class="claro">
    <div id="map" style="width:1000px; height:600px; border:1px solid #000;"></div>
    <div id="timeSliderDiv"></div>
  </body>
</html>

0 Kudos
DerekMiller
New Contributor III
Hi Kelly,

I have been able to display the 2012 points as well after I increased the max feature count from 1000 to 2000 on AGS (the map service you tried to repro with), with no change to the original code.

I still don't know why the timeExtent on the featureLayer didn't match the timeExtent in the service definition. Max feature count is all I could come up with.

If you'd like to test, the url below has the same service with max feature count set to 1000 :

http://cgisagsec2.portlandoregon.gov/arcgis/rest/services/BPS/solar_pdx1000/MapServer/0

Thanks for the response, Kelly. I appreciate it.

- d
0 Kudos
KellyHutchins
Esri Frequent Contributor
Ran a quick test using the second service and it worked for me. I used the same sample as posted above just switched out the url to the service.
0 Kudos
DerekMiller
New Contributor III
Ran a quick test using the second service and it worked for me. I used the same sample as posted above just switched out the url to the service.


That's interesting, Kelly. I appreciate you looking into this.

I just ran the sample you posted previously with both service urls. The service with the max feature count set to 1000 (default) does not show the 2012 records, while the service set to 2000 max feature does. The two screen captures below illustrate (the point West of 82nd on Henry is a 2012 record).

Max Feature Count 2000 : service url http://cgisagsec2.portlandoregon.gov/arcgis/rest/services/BPS/solar_pdx/MapServer/0

[ATTACH=CONFIG]20987[/ATTACH]

Max Feature Count 1000 : service url http://cgisagsec2.portlandoregon.gov/arcgis/rest/services/BPS/solar_pdx1000/MapServer/0

[ATTACH=CONFIG]20988[/ATTACH]

It seems we are experiencing differing results.
0 Kudos
KellyHutchins
Esri Frequent Contributor
Is there a reason why you don't want to use an ArcGISDynamicMapServiceLayer in this case? If you have a large number of features this may be a better approach.
0 Kudos
DerekMiller
New Contributor III
Is there a reason why you don't want to use an ArcGISDynamicMapServiceLayer in this case? If you have a large number of features this may be a better approach.


What do I gain by using an ArcGISDynamicMapServiceLayer? Would I not have to send a request to the server each time I update a layer definition? I can handle that client-side with a FeatureLayer.

FeatureLayers provide all the utility that I need, with the exception of this interesting timeExtent issue. If I have to bump the max feature count to 2000, that's not a problem, though I am still curious as to why this is occuring.

Thanks again.

- Derek
0 Kudos
KellyHutchins
Esri Frequent Contributor
Hi Derek,

When you work with feature layers in snapshot mode you get all the features on the client as graphics and the time slider queries for those features without making requests to the server. The problem, as you noted, is that if the max limit is 1000 then you may not get some of the results you suspect because you don't have all the data.
If you modify the sample to add the feature layer in on demand mode you'll see that you do see the results for 2012 but we don't recommend using the Time Slider with Feature Layer's in  on demand mode because it can result in too many requests to the server. If your service that has the max record limit upped to 2000 performs well then use that. If it doesn't then look at using an ArcGISDynamicMapServiceLayer.
0 Kudos
DerekMiller
New Contributor III
Hi Kelly,

That makes sense. I'll stick with the featureLayer unless I find performance issues.

I appreciate the time you've spent looking into this and responding!

Thanks again,

Derek
0 Kudos