Update MKMapView constraints but keep annotations in one place on screen.
I have a mkmapview that has annotations on it. I want to resize the map (by changing the height constraint constant from 200 to 400), but I don't want the map center coordinate to not move at all.
Currently, when the map is resized, the center coordinate is moved so that it remains in the center of the map (from (x, 100) to (x, 200) if the height of the map is 200 to 400).
It seems the only solution for this is to execute the code like this:
var coordinate = self.mapView.centerCoordinate
coordinate.latitude += self.mapView.region.span.latitudeDelta * 0.25;
self.mapView.setCenterCoordinate(coordinate, animated: true)
This works, but the problem I'm running into is mostly animation related . I want to update the constraint in animated mode as well:
mapHeightConstraint.constant = 400
UIView.animateWithDuration(0.35) {
self.view.layoutIfNeeded()
}
This results in the map not animating regardless of whether I change the limit before or after adjusting the center.
I want both animations to run at the same time and take the same amount of time or find a different solution.
source to share
No one has answered this question yet
Check out similar questions: