I have an array, allCollections, that holds programmatically-created arrays of CLLocations the user has recorded through my iOS app. Each sub-array in allCollections holds all the location points in a trip taken.
I draw MKPolylines off of the CLLocations in the arrays in allCollections to represent those trips on an MKMapView. My question is this: With the polylines added to the map, how would I go about programmatically zooming and centering the map to display all of them?
boundingMapRect
to define a rectangle that encompasses the polyline overlay. It then sets the map zoom area to that rectangle withsetVisibleMapRect
taking into account the adjustable padding values withedgePadding
. I found this solution to be the most helpful, since it solves the problem efficiently with few lines of code and also allows for changes to the map view area through insets. – Granthem