AnsweredAssumed Answered

How to set a defintionExpression in JS

Question asked by heathmanderson on Oct 18, 2019
Latest reply on Oct 21, 2019 by heathmanderson

I am struggling getting my definition expression to work with a time aware field.  I believe I have narrowed down the problem to the layer.definitionExpression.  I have successfully made a definition expression for a text field:

 

layer.definitionExpression = "project_type = 'SUP'"

 

but I have been unsuccessful in writing one for a time aware field.  Should I be using the field name {project_date} or 'time'?

 

timeSlider.watch("timeExtent", function() {
          // only show earthquakes happened up until the end of
          // timeSlider's current time extent.
          //defExp = layer.definitionExpression = "time = " + timeSlider.timeExtent.end.getTime();
          //defExp = layer.definitionExpression = "project_type = 'SUP'";
          //defExp = layer.definitionExpression = "time=1571202000000";
          defExp = layer.definitionExpression = "time="+1571202000000;
          defExp2 = layer.definitionExpression = "project_date="+1571202000000;
          //checks definitonExpression
          console.log(defExp);
          console.log(defExp2);

 

I know that the epoch time 1571202000000 exists in my dataset because I can query it in the rest end point and the query yields 2 results, however that doesn't seem directly translate to JS.  Can some one please help me.

 

Outcomes