从 MKMapView 上的 setRegion: 获取不同的输出
这是我的问题:当我尝试设置地图的缩放级别时,我缩放到的级别与我要求的级别不同。
这是我正在使用的代码:
MKCoordinateRegion cRegion =
MKCoordinateRegionMake
(myMapView.userLocation.coordinate, MKCoordinateSpanMake(.001, .0001));
MKCoordinateRegion aRegion = [myMapView regionThatFits:cRegion];
[myMapView setRegion:cRegion animated:YES];
我做的第一件事是创建一个区域,其跨度在纬度方向为 0.001,在经度方向为 0.0001。我的理由是,这将给我一个正好跨越 0.001 度纬度的条子。然后我可以把它扔进regionThatFits:,它会吐出一个跨越0.001度纬度的区域,以及我的地图视图需要在经度方向上跨越的任何区域以保持该纵横比。相反,我得到:
Lat Range: 0.000969508
Long Range: 0.000858307
知道为什么我认为是 0.001 的纬度范围不是吗?
预先感谢您的帮助!
Here is my question: When I am trying to set the zoom level of my map, I is zooming to a different level than I requested.
Here is the code I am using:
MKCoordinateRegion cRegion =
MKCoordinateRegionMake
(myMapView.userLocation.coordinate, MKCoordinateSpanMake(.001, .0001));
MKCoordinateRegion aRegion = [myMapView regionThatFits:cRegion];
[myMapView setRegion:cRegion animated:YES];
The first thing I do is create a region with the span being .001 in the latitude direction and .0001 in the longitude direction. My reasoning is that this will give me a sliver that spans exactly .001 degrees latitude. Then I can throw it into regionThatFits: and it will spit out a region that spans .001 degrees latitude and whatever my map view needs to span in the longitude direction to keep that aspect ratio. Instead I get:
Lat Range: 0.000969508
Long Range: 0.000858307
Any idea why the Lat Range, which I thought would be .001 isn't?
Thanks in advance for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 MKMapView 的 setRegion 中的一个错误。请参阅MKMapView 显示错误保存的区域
This is a bug in the MKMapView's setRegion. See See MKMapView show incorrectly saved region