Dear viewers,
I wonder how I can filter feature layer using new widget "DatePicker".
More specifically, I want to return a date selected in DatePicker and filter the feature layer in featureLayerView. I have tried lots but I am not even certain what is wrong or right.
I am sorry that what I did below does not make sense...
I really appreciate it if you can give me some hints..
// Date Picker
const startDate = new DatePicker({
container: "start-date-picker"
});
view.ui.add(startDate, "bottom-right");
// click event handler for seasons choices
startDate.addEventListener("click", filterByDate);
// User clicks date
// Filter layer by the selected date
function filterByDate(event) {
const selectedDate = event.target.value;
timeLayerView.filter = {
where: "EndDate <= date'" + selectedDate + "'" // time field is "EndDate"
};
}
view.whenLayerView(featureLayer).then(function(layerView) {
timeLayerView = layerView;
});