Select to view content in your preferred language

Automate date filter on webmaps

534
3
01-10-2024 02:05 PM
Labels (2)
KellyTaylor
Regular Contributor

Hey all,

I'm trying to automatically change the filter on a layer on a web map based on the date. For example, I only want points collected in January to show up, but starting in February I only want points collected in February, etc.

I thought about scheduling a notebook, but I don't think you can manipulate an online map with python the way you can with the mapping module in Pro.

I also wrote an attribute expression that returns true if the month of my 'location_timestamp' field is equal to the current month, but I don't see a way to incorporate attribute expressions into a filter. I assumed that was an option, which is why I wrote the expression.

This is obviously not a huge deal but I love a clutter-free map and I love automating things (I picked the right profession!) so I'd love to hear your thoughts!

3 Replies
RhettZufelt
MVP Notable Contributor

One way would be to add a new field, lets call it "Draw" and base your filter on that:

If [Draw] == "yes"

Then, you could schedule a notebook/python script at the end of the month using the Python API to calculate the field values to 'yes' for the features with the appropriate date and set the others to 'no'. 

R_

KellyTaylor
Regular Contributor

Oh, that's a great idea. Thank you!

0 Kudos
DanielleKuchler
Occasional Contributor

Hi Kelly,

I am having this same issue and am wondering if you were able to find a solution. Would you be willing to share any pointers about how you set up your notebook? 

0 Kudos