Turning on time-aware capability

2353
6
10-12-2015 05:31 PM
CherryChan
New Contributor

Hello,

I am trying to create a time slider from a dynamic Json url but it is not going too well. I parsed through the data and manually created a feature layer through the help of the following link: Feature collection | ArcGIS API for JavaScript but can't seem to get any time information.

I have created a esriFieldTypeDate field in the layer definition, formatted the date in YYYYMMDDHHMMSS format and defined the feature layer as Featurelayer.MODE_SNAPSHOT. However when I was trying to access the feature layer's timeinfo properties, the console displayed the value as undefined.

How can I access/enable the time attributes?

Any help would be appreciated.

Tags (1)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Cherry,

   Have to made the layer time aware in ArcMap ("Enable time on this layer" on the time tab in the layers properties dialog) before you published the map service?

0 Kudos
CherryChan
New Contributor

Hi Robert,

I'm using a json feed from external party(http://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2015-09-16&minlatitude=-80&...) and the data needs to be dynamically updated, so I thought a map service does not have the capability to do so.

Is there a way to publish third party feeds as a map service while maintaining its dynamic properties?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Cherry,

   Sorry I must have skipped reading where you were creating the layer based on a feature collection. So the Feature Collection does not have a time extent and that is why it is null. Juts adding an esriFieldTypeDate field does not make the data time aware or produce a time extent.  So you need to look at the docs for TimeExtent:

TimeExtent | API Reference | ArcGIS API for JavaScript

and FeatureLayer setTimeDefinition:

FeatureLayer | API Reference | ArcGIS API for JavaScript | setTimeDefinition

CherryChan
New Contributor

Thanks Robert,

Followed those steps and I'm making some progress. I have another question if you don't mind; when I invoke the featureLayer.setTimeDefinition(timeExtent);

I got the following message in the console log:

FeatureLayer: layer created by value (from a feature collection) does not support definition expressions and time definitions. Layer id = myFeatureLayer

Before I set the time definition, I did set up the feature layer like so:

featureLayer = new FeatureLayer(featureCollection, {
  id: 'myFeatureLayer',
  mode: FeatureLayer.MODE_SNAPSHOT,
  outFields: ["*"]
});
var features = [];

In this case, does that mean time definition it is not supported?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

unfortunately yes that means it is not supported

0 Kudos
CherryChan
New Contributor

Alright, thanks for trying to help Robert!

0 Kudos