Refactor map click event handling