Moved javascript logic for map to map view