IMO it needs to be scripted so you have to mechanically be holding a shovel to be able to trigger the treasure spawn.
I just accidentally walked over a spot that I had a map for and even though I didn't have shovel equipped, it triggered the treasure and ate the map.
It was a map I was holding for someone else too.