Working to implement a time slider for a GeoJSONLayer using ArcGIS JS 4.21, but have run into an issue regarding the formatting of the field in the GeoJSON file.
According to https://doc.arcgis.com/en/arcgis-online/manage-data/work-with-date-fields.htm the closest supported date format for an input file is YYYY-MM-DDThh:mm:ss.s, but the GeoJSON file I am working with has the format of YYYY-MM-DDThh:mm:ss (no fractional second included).
From the timeslider filter example, it looks like the timeslider is expecting unix timestamps.
To clarify my question- how can I get the timeslider to work with GeoJSON date fields that are currently formatted as YYYY-MM-DDThh:mm:ss ?
Example code:
const layer = new GeoJSONLayer({
url: geojsonurl,
geometryType: "point",
title: "Observations",
visible: true,
fields: [
{ name: "ObservationId", type: "string" },
{ name: "MeasuredAt", type: "date" }
],
outfields: ["*"],
timeInfo: {
startField: "MeasuredAt", // name of the date field stored as "2020-06-13T09:33:00"
interval: {
unit: "days",
value: 1
}
}
Example error:
//[object, object]
{
"error":{
"code": null,
"description": "Value 2020-06-25T20:03:00 is not a valid value for the field type -
field: MeasuredAt,
type: esriFieldTypeDate,
nullable: true"
}
}
Thanks for any pointers.
Solved! Go to Solution.
Hi there,
So the GeoJSONLayer creates date fields if the GeoJSON feature properties contain unix/epoch timestamp. In your case, feature property contains ISO 8601 strings. So you will need to:
This test app shows everything I listed above. However, this app needs to be updated when you upgrade to 4.22 or above versions. At 4.21, when you intercept the geojson request, the geojson data is returned as array buffers, so you will have to decode those array buffers at 4.21.
At 4.22, we are changing this behavior. We updated the request flow of workers so that an after interceptor receives the expected data type. This means after interceptors that were expecting array-buffers for client-side layers such as GeoJSONLayer and CSVLayer will receive the expected data types json or text. At the very end of this test app, I added an after interceptor function that will work at 4.22.
Lastly, we will update the doc for GeoJSONLayer.timeInfo property to show the workflow we talked about in this discussion.
Hope this helps,
-Undral
Hi there,
So the GeoJSONLayer creates date fields if the GeoJSON feature properties contain unix/epoch timestamp. In your case, feature property contains ISO 8601 strings. So you will need to:
This test app shows everything I listed above. However, this app needs to be updated when you upgrade to 4.22 or above versions. At 4.21, when you intercept the geojson request, the geojson data is returned as array buffers, so you will have to decode those array buffers at 4.21.
At 4.22, we are changing this behavior. We updated the request flow of workers so that an after interceptor receives the expected data type. This means after interceptors that were expecting array-buffers for client-side layers such as GeoJSONLayer and CSVLayer will receive the expected data types json or text. At the very end of this test app, I added an after interceptor function that will work at 4.22.
Lastly, we will update the doc for GeoJSONLayer.timeInfo property to show the workflow we talked about in this discussion.
Hope this helps,
-Undral
Very thorough reply, thank you. Any timetable for 4.22 release?
It will be released end of December 2021.