I am providing and rendering MapKit tiles in a usual way:
class TileOverlay: MKTileOverlay {
override func url(forTilePath path: MKTileOverlayPath) -> URL {
// Calculate URL for index path
return url
}
}
public override func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer? {
if let overlay = overlay as? TileOverlay {
let renderer = OverlayRenderer(tileOverlay: overlay)
return renderer
}
return nil
}
open class OverlayRenderer : MKTileOverlayRenderer {
override open func draw(_ mapRect: MKMapRect, zoomScale: MKZoomScale, in context: CGContext) {
UIGraphicsPushContext(context)
super.draw(mapRect, zoomScale: zoomScale, in: context)
UIGraphicsPopContext()
}
public override init(overlay: MKOverlay) {
super.init(overlay: overlay)
self.alpha = 0.5
self.blendMode = .multiply
}
}
That works fine, but I need to access Apple's underlying image for pre-processing before or when performing the MKTileOverlayRenderer draw function.
I have reviewed documentation and searched high and low for a way to access the base imagery but have yet to find a solution. So, I thought the best way to solve the issue was to request the imagery with MKMapSnapshotter and pre-tile it. However, it has been hinted that there is a way to access the underlying images, see: