简体   繁体   English

iOS - 某些图块未在自定义 MKTileOverlay 中呈现

[英]iOS - Some tiles not rendered in a custom MKTileOverlay

I have a custom MKTileOverlay in my iOS project using MapKit, it works fine most of the time.我在我的 iOS 项目中使用 MapKit 有一个自定义的 MKTileOverlay,它大部分时间都可以正常工作。 However, after zooming in/out a few times and panning the map some of the tiles are not being drawn.但是,在放大/缩小几次并平移地图后,一些图块没有被绘制。

At first I thought it was a simple case of tiles not being loaded so I subclassed the MKTileOverlay and added logging in the console.起初我认为这是一个没有加载瓷砖的简单情况,所以我对 MKTileOverlay 进行了子类化并在控制台中添加了日志记录。 It showed that all tiles were loaded perfectly fine and delivered to the result block.它表明所有瓷砖都被完美地加载并交付到结果块。

As I was running out of ideas I created a local tile generator that just returns images with their path x/y/z and frame drawn to see what tiles are missing.由于我的想法不多了,我创建了一个本地图块生成器,它只返回带有 x/y/z 路径和绘制的框架的图像,以查看缺少哪些图块。

Missing tile example image缺少图块示例图像

Unfortunately the problem persists even with locally generated tiles so it has nothing to do with Internet connectivity.不幸的是,即使使用本地生成的图块,问题仍然存在,因此它与 Internet 连接无关。 Another weird behaviour is that if I have two custom overlays on top of one another, it will be exactly the same tiles that are not being rendered on both overlays.另一个奇怪的行为是,如果我有两个自定义叠加层,它们将是完全相同的图块,但不会在两个叠加层上呈现。

The only solution I can think of right now is subclassing the tile renderer and making sure that everything is displayed as there is no way to know that the tile is not rendered.我现在能想到的唯一解决方案是将 tile 渲染器子类化并确保显示所有内容,因为无法知道 tile 未呈现。 This, however, sounds like a lot of work and a "reinventing the wheel" kinda task...然而,这听起来像是很多工作和“重新发明轮子”的任务......

We were also experiencing this problem of missing tiles - trying to draw map tiles around New Zealand.我们也遇到了缺少图块的问题 - 尝试在新西兰周围绘制地图图块。 The MKOverlayRenderer was not even requesting the tiles. MKOverlayRenderer 甚至没有请求切片。 We went down a rabbit hole thinking it must be because New Zealand is near the 180/0 latitude boundary.我们陷入了一个兔子洞,认为这一定是因为新西兰靠近 180/0 纬度边界。 Nope.不。 It was because the sub-classed method:-这是因为子类方法:-

- (void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData * __nullable data, NSError * __nullable error))result;

Must always call the result method even if there is no data to return!即使没有要返回的数据,也必须始终调用 result 方法! To give credit where credit is due this was the source of the solution for us:-在应得信用的情况下给予信用,这是我们解决方案的来源:-

MKTileOverlay not drawing every tile? MKTileOverlay 没有绘制每个图块?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM