Fix some logic in adding marker js