关于在 iOS 中旋转地图

发布于 2024-10-15 10:27:26 字数 191 浏览 0 评论 0原文

我在尝试在 iPhone 应用程序中旋转地图时遇到这个问题

。视图被剪切并且旋转也会发生。我想避免剪辑。有什么建议吗?

继承人的代码:

viewToRotate.layer.transform = CATransform3DMakeRotation(0.8, 0., 0., 1.);

I am facing this problem while trying to rotate the map in my iPhone app

The view gets clipped and rotation also happens. I want to avoid the clipping. Any tips ?

heres the code:

viewToRotate.layer.transform = CATransform3DMakeRotation(0.8, 0., 0., 1.);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

热情消退 2024-10-22 10:27:26

您需要 3D 旋转地图吗?如果没有(我认为您需要的是),那么只需使用 CGAffineTransformMakeRotation 即可(请小心,因为它需要以弧度为单位的角度)。

另外,如果您不希望地图被裁剪,则需要使地图更大,如下图所示(在新选项卡中打开以查看更大的地图)

http://img593.imageshack.us/img593/4498/calculatemapboundswhenr.png

首先,您需要计算矩形的对角线(您的可见地图)如上图所示(我称之为“半径”,因为这将是比矩形大的最小圆的半径)。

其次,使用半径,您需要计算(最小)正方形,使您的地图无需裁剪即可查看。该方块将用于设置地图的边界(注意:不是frame - Apple 规定,在使用旋转时,不应使用frame< /code> - 只是边界和/或中心)。

确保该正方形位于可见地图矩形的中心(即,该正方形应在小矩形上方和下方有 X 像素...以及小矩形左侧和右侧的 Y 像素)。

希望有帮助!

You need your map rotated in 3D ? If not (which is what I think you need), then just use CGAffineTransformMakeRotation (be careful, as it requires the angle in radians).

Also, if you don't want your map to be clipped, you need to make your map bigger, like in the image below (open in new tab to see it bigger)

http://img593.imageshack.us/img593/4498/calculatemapboundswhenr.png

First, you need to calculate the diagonal of the rectangle (your visible map) as instructed in the image above (which I call "radius" because that would be the radius of the smallest circle bigger than your rectangle).

Second, using the radius, you need to calculate the (smallest) square that will allow your map to be seen without clipping. This square will be used to set the bounds of your map (caution: NOT the frame - Apple specifies that, when using rotation, you should not use frame - just bounds and / or center).

Make sure this square is centered on the center of your visible map rectangle (i.e. the square should have X pixels above AND below the small rectangle ... and Y pixels left AND right of the small rectangle).

Hope it helps !

后eg是否自 2024-10-22 10:27:26

你有找到解决办法吗?

我能做到的唯一方法是使 Interface Builder 中的 MapView 比其应覆盖的屏幕区域的实际大小大得多,然后我将 MapView 居中,使其中心位于较窄的可视区域的中心。

旋转的工作方式似乎与内置地图应用程序中的工作方式类似。

我的猜测是,您必须这样做,以便从 Google 流入的图像图块覆盖足够宽的区域,可以说“填补空白”,即使它们并不总是可见。

如果您应用一点数学知识,您可能可以通过编程方式调整 MapView 的大小和位置,从而避免剪切,但不需要比绝对必要更多的图块。

Did you ever figure out the solution?

The only way I could do it was to make the MapView in Interface Builder much bigger than the actual size of the screen area its supposed to cover, then I centered the MapView such that its center was in the center of the narrower viewable area.

Rotation seemed to work similarly to how it works in the built-in Maps app.

My guess is that you have to do this so that the image tiles streaming in from Google cover a wide enough area to "fill in the blanks" so to speak, even if they're not always visable.

If you apply a little math, you could probably programmatically size and position the MapView such that you void clipping, but don't require more tiles than is absolutely necessary.

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