I have coordinates of a single pin on my map. I try to center my map on that pin, but I don't want to keep the pin directly in the middle of the map, but in 1/3 of the screen. I tried to do it in the following workaround:
let coordinateRegion = MKCoordinateRegionMakeWithDistance(coordinatesOfThePin, 500, 500)
mapView.setRegion(coordinateRegion, animated: true)
let frame = mapView.frame
let myPoint = CGPointMake(frame.midX, frame.midY/3)
let myCoordinate = mapView.convertPoint(myPoint, toCoordinateFromView: mapView)
let coordinateRegion2 = MKCoordinateRegionMakeWithDistance(myCoordinate, 500, 500)
mapView.setRegion(coordinateRegion2, animated: true)
but it shows random positions depending on the first position of the map. Can you help me with rewriting my code so that I could just put a pin location and get the result as follows:
-------------------
| |
| |
| X | <-- my pin in the 1/3 of the visible map area.
| |
| |
| |
| |
| |
| |
| |
| |
-------------------