I would like to know how to centre a route on a MapView. Or how to calculate the center to ensure that both points are also visible on the mapview?
At present I use the setRegion
method with some custom calculations to work out the zoom.
[_mapView setRegion:viewRegion animated:YES];
I see that I can also use setVisibleMapRect: edgePadding: animated:
but I am not sure how to get a MKMapRect for use.
I find the address of a business with geocodeAddressString
then have a CLPlaceMark
result.
I have an MKPointAnnotation
which is the pin for the destination (business).
I then create a MKDirectionRequest
to an MKPlaceMark
created from the CLPlaceMark
. I then display the route.
How do I zoom in to a specific amount based on this workflow, so that I could get a result like these below. Specifically where the route is centered in the mapView and both user location and the annotation are shown on screen without being miles/very far out?