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:
(null)
Solved! Go to Solution.
Isra,
For that you will have to edit the actual mxd that the service is coming from.
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>
But can I change the field itself
I meant this one
Can I change it to another Date type field? Or it's not possible?
Isra,
For that you will have to edit the actual mxd that the service is coming from.