Manage js state of polygon events
Move event polygon behavior to functions