MKMapView centerCoordinate不精确 [英] MKMapView centerCoordinate not exact

查看:158
本文介绍了MKMapView centerCoordinate不精确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用 MKMapView的centerCoordinate 将图钉放置在地图中心时,它会在图钉的大致中心位置放置一个图钉,但它在地图真实中心的南数个像素处.

When I try to place a pin in the center of the map using MKMapView's centerCoordinate it puts a pin roughly in the center, but it's several pixels south of the true center of the map.

我尝试将地图的中心点转换为坐标 MKMapView.convertPoint(MKMapView.center),该功能在ios8上运行良好,但在ios7上仍处于关闭状态(现在位于真实中心的南面和西面).

I tried converting the map's center point to a coordinate MKMapView.convertPoint(MKMapView.center) and that worked perfectly on ios8 but on ios7 is still off (now its south and west of the true center).

任何人都知道如何确定中心坐标的偏离"程度,以便我进行调整吗?

Anyone know how to determine how "off" the center coordinate is so I can adjust?

我需要这个,因为我要在地图上放置一个十字准线图像,并且需要将图钉显示在十字准线的中心.我已经用标尺验证了十字准线在地图上居中,这是固定的针脚.

I need this because I am placing a crosshair image over the map and need the pin to appear in the center of the crosshair. I've verified with a ruler that the crosshair is centered on the map, it's the pin that is off.

推荐答案

我还是不知道为什么在iOS7中MKMapView.convertPoint(MKMapView.center)与MKMapView.centerCoordinate不同,但是确实弄清楚了为什么.centerCoordinate被关闭了

Well I still don't know why in iOS7 MKMapView.convertPoint(MKMapView.center) differs from MKMapView.centerCoordinate, but did figure out why .centerCoordinate was off.

地图的一部分在状态栏下,我根据可见部分确定中心,并叠加以可见部分为中心的图像,但地图基于整个地图计算中心.因此,一旦我修复了地图无法在状态栏下运行的情况.centerCoordinate可以运行,并且在iOS7上比MKMapView.center更好.

Part of the map was under the status bar and I ruled the center based on the visible part and overlaying images centered on the visible part, but the map computed center based on the whole map. So once I fixed the map not running under the status bar .centerCoordinate works and, on iOS7, works better than MKMapView.center.

这篇关于MKMapView centerCoordinate不精确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆