Select to view content in your preferred language

Web map symbols by time range

583
1
06-04-2021 06:08 PM
Labels (2)
AndyGeo
Emerging Contributor

Hello all,

 

I am trying to build a map that shows points from a Survey based on the age of the submission.

I am trying to get the points to change color based on their age from the current timestamp. I'm sure I have something wrong in the code (which is not my strong suit). I found this code in the forum from a few years ago. It was built using 2 variables plus an else = current option. I need to have at least 3 time variables with time ranges. Any help is greatly appreciated.

 

Thanks,

Andy

 

For records less than 30 min = Green

For records >30<60 min = Orange

For records >60 min = Red

 

var time1 = Date($feature.CreationDate)
if(DateDiff(Now(), time1, 'minutes')<30){
Var Status = "<30 min";
}
else if(DateDiff(Now(), time1, 'minutes')>30<60){
var Status = ">30<60 min";
}
else if(DateDiff(Now(), time1, 'minutes')>60){
var Status = ">60 min";
}
return Status

1 Reply
AndyGeo
Emerging Contributor

I think I solved it. Here is what I did and it seems to be working they way I want it.

 

var repTime = Date($feature["activity_date"]);
var curTime = Now();
var age = DateDiff(curTime, repTime, 'minutes');

if(age <30) {
return '<30 min ago';
}
else if(age >=30 && age <=60) {
return '30-60 min'
}
else {
return '>60 min'
}