So I am using this call:
mapView.showAnnotations(annotations, animated: true)
to animate the app to show the annotations. That works great. What I need on top of that, is to tell the Map to add 100 pixels of padding to the left of the region that it normally zooms to when I call:
mapView.showAnnotations(annotations, animated: true)
I have a view over the map on the left side of the screen and I don't want the annotations appear under, so, I want to add padding to the left of them so they're not hidden by the view.
I tried the MKMapView calls "setRegion" and:
mapView.setVisibleMapRect(mapRect, edgePadding: UIEdgeInsetsMake(20, 100, 20, 20), animated: true)
but, it's not really working especially when I try to combine the:
mapView.showAnnotations(annotations, animated: true)
and:
mapView.setVisibleMapRect(mapRect, edgePadding: UIEdgeInsetsMake(20, 100, 20, 20), animated: true)
What is the correct way to achieve this?
ok, so the answer that is listed as the reason why this could be a possible dup does have the information I was looking for, but not it its official answer. That answer does not work for me. The padding is off and it looks weird. It's also way more involved than the one line solution I found scanning that whole post.... So, if this is going to be considered a dup its out of my control, but I will post here the answer that actually worked for me WHICH IS NOT the accepted answer for that post.
What worked for me is the super simple one line of code:
mapView.layoutMargins = UIEdgeInsetsMake(0, 100, 0, 60)
so this allows me to then use the map as usual and have the map automatically handle all the layout logic respecting the merging setting, so no annotation is placed under the left view I have over the map.