Hello,
Is there anyone who can figure out my mistake ?
I want to to visualize point on map that have the difference of 5 minutes from current time to the time that is mentioned in database.
I have mentioned or code the time difference in the arcade expression but unfortunately its not working. Please guide me how can I resolve it.
Regards,
Kawish
let dates = new Date();
let lastSevenDays = new Date(dates);
lastSevenDays.toDateString();
lastSevenDays.setDate(lastSevenDays.getDate() - 7);
let year = lastSevenDays.getFullYear();
let month = (date) => {
const m = date.getMonth() + 1;
if (m.toString().length === 1) {
return `0${m}`;
} else {
return m;
}
};
let date = ("0" + lastSevenDays.getDate()).slice(-2);
let complete_date = year + "-" + month(lastSevenDays) + "-" + date;
const name = "$feature.alarmstate";
const cat = "$feature.category";
const week = "$feature.lastdowntime";
const ticketStatus = "$feature.ticketstatus";
let c_date = new Date();
let d = new Date(week);
let diff = c_date.getMinutes() - d.getMinutes();
if (Math.abs(diff) <= 5)
console.log(c_date.getMinutes(), d.getMinutes(), "Diff - ", diff);
let value = 5;
const valueExpression = `When(
${name} == 2 && ${cat} == 'VIP' && ${week} >= '${complete_date}', 'two',
${name} == 2 && ${cat} == 'VIP' && ${week} <= '${complete_date}', 'two_1',
${name} == 2 && ${Math.abs(c_date.getMinutes() - new Date(week).getMinutes())
} <= 5, '5Min', 0)`;
var rendererCheck = {
type: "unique-value",
valueExpression: valueExpression,
uniqueValueInfos: [
{
value: "5Min",
symbol: {
type: "picture-marker",
url: "images/down-arrow-red.gif",
width: "35px",
height: "40px",
xoffset: 0,
yoffset: 12,
},
},
{
value: "two",
symbol: {
type: "picture-marker",
url: "images/two.png",
color: "red",
width: "25px",
height: "25px",
},
},
{
value: "two_1",
symbol: {
type: "picture-marker",
url: "images/two_1.png",
color: "red",
width: "24px",
height: "24px",
},
},
{
value: 0,
symbol: {
type: "simple-marker",
style: "circle",
color: "white",
size: "6.5px",
outline: {
color: [255, 255, 255, 1],
width: 0.4,
},
},
},
],
};