This sample demonstrates how to use time-aware layers to visualize the progression of the 2019 Kincade fire. Starting with version 5.2, the service backed FeatureLayer can be made time-aware by setting its timeInfo property to use the recordedDate field. The GraphicsLayers do not have time values stored in an attribute field, so each one uses visibilityTimeExtent to define the date when it should be visible.

The Time Bar component allows you to move through the fire’s timeline. As the current time changes, the FeatureLayer displays the matching fire perimeter, while the corresponding GraphicsLayer displays additional information for that date.

How it works

When the app loads, a query is made against all fire perimeters in the Kincade fire feature service. The query results are ordered by the recordedDate field. For each perimeter, the app creates a GraphicsLayer and sets its visibilityTimeExtent to the perimeter’s recordedDate. It then creates a graphic with a text symbol whose text property is set using the feature’s Notes attribute, and adds the graphic to the GraphicsLayer.

// Store the unique recorded dates from the Kincade fire perimeters.
const dates = [];
// Query the perimeters in recorded date order.
const query = featureLayer.createQuery();
query.orderByFields = ["recordedDate"];
const queryResult = await featureLayer.queryFeatures(query);
// Create a dated GraphicsLayer and note label for each perimeter.
queryResult.features.forEach((feature, i) => {
const date = new Date(feature.attributes.recordedDate);
const notes = feature.attributes.Notes;
const centroid = centroidExecute(feature.geometry);
// Label each perimeter with its notes attribute.
const graphic = new Graphic({
geometry: {
type: "point",
x: centroid.x,
y: centroid.y,
spatialReference: {
wkid: 102100,
},
},
symbol: new TextSymbol({
text: `On ${date.toLocaleDateString("en-US")}\n\n${notes}`,
color: "black",
xoffset: 50,
yoffset: 10,
lineWidth: 200,
horizontalAlignment: "left",
backgroundColor: "white",
font: {
size: 12,
family: "sans-serif",
},
}),
});
// Show each graphics layer only for its recorded date.
const graphicsLayer = createGraphicsLayer(date, i);
graphicsLayer.add(graphic);
viewElement.map.add(graphicsLayer);
if (!dates.some((d) => d.getTime() === date.getTime())) {
dates.push(date);
}
});
// Set the timeInfo for the feature layer based on the recorded dates.
featureLayer.timeInfo = {
fullTimeExtent: {
start: dates[0],
end: dates[dates.length - 1],
},
startField: "recordedDate",
};

The createGraphicsLayer() function creates a new GraphicsLayer and sets its visibilityTimeExtent to match a given date as shown below.

// Create a GraphicsLayer that is visible only for one date.
function createGraphicsLayer(date, index) {
const graphicsLayer = new GraphicsLayer();
graphicsLayer.id = `graphicsLayer${index}`;
graphicsLayer.visibilityTimeExtent = {
start: date,
end: date,
};
return graphicsLayer;
}

The Time Bar component is configured to display only the play button because the GraphicsLayers display the date and notes for each day as the Kincade fire perimeters are animated.

<arcgis-time-bar slot="bottom-left" mode="instant" show-play play-rate="2000"></arcgis-time-bar>

Additionally, the Time Bar’s stops are set to the dates array, and its initial timeExtent is set to the first date. As the current timeExtent changes, each GraphicsLayer is visible when its visibilityTimeExtent overlaps the Time Bar’s timeExtent, displaying the additional information for that date.

// Set the time bar stops and initial time extent.
timeBar.stops = { dates };
timeBar.fullTimeExtent = new TimeExtent({
start: dates[0],
end: dates[dates.length - 1],
});
timeBar.timeExtent = new TimeExtent({
start: dates[0],
end: dates[0],
});
2D5.2timetimeInfoFeatureLayerGraphicsLayervisibilityTimeExtentFeatureEffectQueryeffectgeometry operatorcentroidOperatorviewOnReadyarcgis-maparcgis-time-bararcgis-zoommap-components