Refactored initialize function for mapView