MKOverlayView:drawMapRect 中的裁剪

发布于 2024-09-26 01:35:27 字数 701 浏览 4 评论 0原文

我在绘制到 MKOverlayView 派生类中传递给 drawMapRect:mapRect:zoomScale:inContextMKMapRect 之外的区域时遇到问题。我试图为集合中的每个坐标绘制一个三角形,当坐标靠近 MKMapRect 边缘时会出现问题。有关问题的示例,请参见下图。

alt text

在图像中,浅红色框表示每次调用时渲染的 MKMapRect drawMapRect。该问题如红色圆圈所示,如您所见,仅渲染了三角形的一部分。我假设它被剪切到 MKMapRect ,尽管 MKOverlayView:drawMapRect 的文档让我认为这不应该发生。

从文档中:

您也不应该假设视图的框架与覆盖层的边界矩形相匹配。视图的框架实际上比边界矩形更大,以便您可以为可能直接位于该矩形边界上的道路等对象绘制线条。

我当前的解决方案是多次绘制对象,如果它们位于比给drawMapRect 的maprect 稍大的maprect 中,但这会导致我绘制一些超出需要的东西。

有谁知道有什么方法可以增加drawMapRect中剪切区域的大小,这样这就不是问题了?也欢迎任何其他建议。

I'm having an issue with drawing to areas outside of the MKMapRect passed to drawMapRect:mapRect:zoomScale:inContext in my MKOverlayView derived class. I'm trying to draw a triangle for each coordinate in a collection and the problem occurs when the coordinate is near the edge of the MKMapRect. See the below image for an example of the problem.

alt text

In the image, the light red boxes indicate the MKMapRect being rendered in each call to drawMapRect. The problem is illustrated in the red circle where, as you can see, only part of the triangle is being rendered. I'm assuming that its being clipped to the MKMapRect, though the documentation for MKOverlayView:drawMapRect makes me think this shouldn't be happening.

From the documentation:

You should also not make assumptions that the view’s frame matches the bounding rectangle of the overlay. The view’s frame is actually bigger than the bounding rectangle to allow you to draw lines for things like roads that might be located directly on the border of that rectangle.

My current solution is to draw objects more than once if they are in a maprect that is slightly larger than then maprect given to drawMapRect but this causes me to draw some things more than needed.

Does anyone know of a way to increase the size of the clipping area in drawMapRect so this isn't an issue? Any other suggestions are also welcome.

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

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

发布评论

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

评论(1

似狗非友 2024-10-03 01:35:27

我最终将一个缓冲区添加到传递给 drawMapRect:mapRect:zoomScale:inContext 的矩形中,并使用它来确定要绘制的对象。这会导致绘制超出需要的对象,但数量不多。

I ended up adding a buffer to the rect passed in to drawMapRect:mapRect:zoomScale:inContext and using that to determine which objects to draw. This results in more objects being drawn than needed, but not by much.

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