从 MKMapView 上的 setRegion: 获取不同的输出

发布于 2024-08-26 02:23:42 字数 686 浏览 1 评论 0原文

这是我的问题:当我尝试设置地图的缩放级别时,我缩放到的级别与我要求的级别不同。

这是我正在使用的代码:

        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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不一样的天空 2024-09-02 02:23:42

这是 MKMapView 的 setRegion 中的一个错误。请参阅MKMapView 显示错误保存的区域

This is a bug in the MKMapView's setRegion. See See MKMapView show incorrectly saved region

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文