我的地图上有一个大头针的坐标。我尝试将我的地图放在那个大头针的中心,但我不想把大头针直接放在地图的中间,而是放在屏幕的 1/3 处。我试图在以下解决方法中做到这一点:
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)
但它会根据地图的第一个位置显示随机位置。你能帮我重写我的代码,这样我就可以放置一个引脚位置并获得如下结果:
-------------------
| |
| |
| X | <-- my pin in the 1/3 of the visible map area.
| |
| |
| |
| |
| |
| |
| |
| |
-------------------