Refactor code into 'placeMarker' event handler