Change the Start Time Field in time aware layers

3298
3
Jump to solution
03-30-2016 08:09 AM
IsraAlhamood
New Contributor II

Hello everyone,

I implemented a simple map viewer for time aware layers. it has a time slider.

I'm trying to change the start time field to another date field in the map layer.

How can I do that?

Time Info:

    • Start Time Field: WB_SPUD_DT

      End Time Field: null

      Track ID Field:

      null

      Time Extent:
        [1935/01/01 00:00:00 UTC, 2016/01/01 00:00:00 UTC]
      Time Reference:

      N/A

      Time Interval: 5

      Time Interval Units: esriTimeUnitsYears

      Has

      Live Data: false

      Export Options:
        Use Time: true

      Time Data Cumulative: false

      Time Offset:

      null

(null)

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Isra,

  For that you will have to edit the actual mxd that the service is coming from.

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Isra,

  Here is how to define the the start time:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <title></title>


    <link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.16/dijit/themes/tundra/tundra.css">
    <link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.16/esri/css/esri.css">


    <style>
      html, body, #map {
        height: 100%; width: 100%; margin: 0; padding: 0;
      }
      #loading {
        width:100%;
        position:absolute;
        height:400px;
        background:transparent url("https://dl.dropboxusercontent.com/u/2654618/ajax-gear.gif") center no-repeat;
        z-index:100;
      }
    </style>


    <script src="//js.arcgis.com/3.16/"></script>
    <script>
      var map;


      require([
        "esri/map", "esri/InfoTemplate",
        "esri/layers/FeatureLayer",
        "dojo/parser", "dojo/dom-construct", "esri/TimeExtent",
        "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
        "dojo/domReady!"
      ], function(
        Map, InfoTemplate,
        FeatureLayer,
        parser, domConstruct, TimeExtent
      ) {
          parser.parse();


          map = new Map("mapDiv", {
            basemap: "oceans",
            center: [-100, 40],
            zoom: 4
          });


          // feature service with U2 concerts from 1980 - 2011
          var featuresUrl = "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/U2/FeatureServer/0";
          var layer = new FeatureLayer(featuresUrl, {
            id: "u2",
            infoTemplate: new InfoTemplate(
              "U2 Concerts:  1980  2011",
              "Date:  ${Date:DateFormat(selector: 'date', fullYear: true)}<br>" +
              "Venue:  ${Venue}, ${City}, ${State}<br>" +
              "Tour:  ${Tour}"
            ),
            mode: FeatureLayer.MODE_SNAPSHOT,
            outFields: ["*"]
          });
          console.info(layer.timeInfo);  //This one will be undefined.
          layer.setUseMapTime(true);


          var layerUpdateEnd = layer.on("update-end", function() {
            console.info(layer.timeInfo); //This one will have an actual value because the layer is loaded.
            layerUpdateEnd.remove();
            var timeExtent = new TimeExtent();
            timeExtent.startTime = new Date("1/1/1989 UTC");
            map.setTimeExtent(timeExtent);
            domConstruct.destroy("loading");
          });


          map.addLayer(layer);
        }
      );
    </script>
  </head>
  <body class="tundra">
    <div class="demoLayout" style="height: 100%; width: 100%"
         data-dojo-type="dijit/layout/BorderContainer"
         data-dojo-props="design: 'headline'">
        <div class="centerPanel"
             data-dojo-type="dijit/layout/ContentPane"
             data-dojo-props="region: 'center'">
          <div id="mapDiv"
            data-dojo-type="dijit/layout/ContentPane"
            data-dojo-props="region:'center'">
            <div id="loading"></div>
          </div>
        </div>
    </div>
  </body>
</html>
IsraAlhamood
New Contributor II

But can I change the field itself

I meant this one

  • Start Time Field: WB_SPUD_DT

Can I change it to another Date type field? Or it's not possible?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Isra,

  For that you will have to edit the actual mxd that the service is coming from.

0 Kudos