I used MKTileOverlay class to cover the map by self generated tile images.
All works good, except the tiles on the border at Longitude 180 or -180 degree. At this line, tiles are drawn only sometimes... can anybody give me a hint to solve that?
you can see the effect on this screenshot
This particular area of the map should be covered completely by this "default" tiles. The tile images itself should be OK, as they are displayed on the other tiles.
I use this loadTile(at: ... ) function to provide the generated tile images. The print statements shows that this function is called for all tiles and that the result function gets a valid image. It's just that the tiles are not drawn .. and I use the standard MKTileOverlayRenderer..
override func loadTile(at path: MKTileOverlayPath, result: @escaping (_ data: Data?, _ error: Error?) -> Void) {
let x: Int = path.x
let y: Int = path.y
let zoomLevel : Int = path.z
// calculate the x for the tile at longitude 180 degree
let xMax = (1 << zoomLevel) - 1
if (x == 0) || (x == xMax) {
print("\(zoomLevel)/\(x)/\(y) requested")
}
// local variable to hold the image of the tile
var localUIImage: UIImage = tileImageForDefaultImage
// lots of stuff to generate the tile image
// check if we have a valid image
if let resultImage = localUIImage.pngData() {
if (x == 0) || (x == xMax) {
print("resultImage: \(resultImage.debugDescription)")
}
result(resultImage, nil )
} else {
let noResultImage = tileImageForDefaultImage.pngData()
if (x == 0) || (x == xMax) {
print("noResultImage: \(noResultImage.debugDescription)")
}
result(noResultImage, nil )
}
}
.. any hint is welcomed ;-)
In short: Apple confirmed that this is a bug in IOS MapKit. At least IOS versions 11 and 12 are affected. There is no known work around so far.
Long version: I spend a DTS ticket for this and got in contact with a really good Apple engineer. After some work together, he could easily reproduce the issue. He asked me to file a bug report (49270907). By this he was able to talk to the MapKit team and they confirmed the bug.