I have a custom MKTileOverlay in my iOS project using MapKit, it works fine most of the time. 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. 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.
Missing tile example image
Unfortunately the problem persists even with locally generated tiles so it has nothing to do with Internet connectivity. 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. 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. We went down a rabbit hole thinking it must be because New Zealand is near the 180/0 latitude boundary. 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! To give credit where credit is due this was the source of the solution for us:-
MKTileOverlay not drawing every tile?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With