2

The tiles are loaded from disk via loadTileAtPath / URLForTilePath with a subclassed MKTileOverlay.

When setting the maximumZ of the overlay, tiles beyond that level are (as expected) no longer loaded. However, the tiles of the level above also disappear. Any ideas?

Jens Habegger
  • 5,266
  • 41
  • 57

1 Answers1

2

It's been a while for me, but I had some issues with this in the past. I think it could be something with the internal caching or the overlays.

For example, if it happens to be the case that the tiles disappear at the transition from zoom level 20 to zoom level 21, and it is also the case that your tile source has a maximum zoom level of 20, then the behavior you're seeing could be a result of polylines invalidating portions of MKMapView's rendered tile cache.

It could be that what you're seeing might be happening because your tile source doesn't provide tiles at a high enough zoom level for the amount of zooming you're attempting to do. Normally Apple's MKMapView render cache provides some limited overzooming, but when you do something that triggers a new render (like adding lines), the render cache gets invalidated and the pseudo-overzooming stops working.

However, I also once saw a fix simply by changing the level for the overlay, Changed from "MKOverlayLevelAboveLabels" to [mapView addOverlay:overlay level:MKOverlayLevelAboveRoads];

I hope these suggestions can get you a bit further :)

Bob de Graaf
  • 2,630
  • 1
  • 25
  • 43
  • Thank you Bob for that list of possible problem sources. Unfortunately, that is pretty much everything I've tried so far (I realize now that my Question is rather incomplete in that concern, sorry for that.) Some details: I do not use any other Overlay Source other than the actual Tiles I want to display, therefore uninteded cache invalidation due to additional polylines seems unlikely. I can zoom "back" to levels that were shown before without re-triggering the load functions for these tiles. I've tried MKOverlayLevelAboveLabels/level:MKOverlayLevelAboveRoads without success – Jens Habegger Jan 03 '20 at 08:49
  • @JensHabegger Thanks for the additional info, and do you use any poly lines as well? The system redraws the squares that lie under polylines to resize the lines and when it does so it clears the tile images and looks for the tiles for the new zoom level. Since it doesn't have those tiles, those squares wind up empty on the tiles level, though squares not overlapped by polylines are not cleared and so retain the old images. Also, did you subclass MKTileOverlay so that you can set the location and size of the area mapped by the tiles? – Bob de Graaf Jan 03 '20 at 09:11
  • @JensHabegger I also found this question where the answers might help you: https://stackoverflow.com/questions/4351724/preventing-overlays-from-disappearing-when-zoomed-mkmapview-mkoverlay – Bob de Graaf Jan 03 '20 at 09:13
  • no additional polylines whatsoever, just a single custom MkTilesOverlay implementation. Yes, I subclassed MKTilesOverlay, the actual position and zoom level work quite nicely. AFAIKS, the answer you linked has no additional solution? – Jens Habegger Jan 08 '20 at 07:45
  • Ah I hoped the accepted answer and the one below had some code samples that might show you a difference with your own code and perhaps solve your issue. But maybe not I guess... I'm not sure how to help you more now. Perhaps you could post your code (if possible) and I can take a look at it? – Bob de Graaf Jan 08 '20 at 15:10
  • I'm afraid we've since decided to move away from MapKit and use a proprietary framework, I'll accept your answer and grant the bounty for your effort anyways. – Jens Habegger Jan 08 '20 at 15:28
  • 1
    Ah too bad. I appreciate the bounty, I sincerely hope the answer might help someone else someday. – Bob de Graaf Jan 08 '20 at 16:06
  • Maybe it's a bit late, but for anyone looking for a solution, this might help: https://stackoverflow.com/questions/4417545/calculating-tiles-to-display-in-a-maprect-when-over-zoomed-beyond-the-overlay – user10253771 Mar 08 '23 at 02:26