Utilizing MKOverlay `canReplaceMapContent` on only part of the MKMap content

134 Views Asked by At

I have created an overlay that I want to cover the whole world except a specific region where the app is focused. I subclassed MKPolygon as follows:

class ReplacingPolygion:MKPolygon{
    override func canReplaceMapContent()->Bool{
        return true
    }
    override var boundingMapRect: MKMapRect { MKMapRect.world }
}

As I understand it, this means that my overlay will replace existing map content and be drawn on the whole world. I have initialized the above class with coordinates that cover the whole world Map except the interior polygon which cuts my needed region out from the larger overlay. Thus, this creates an overlay for the whole world except the region I want.

ReplacingPolygion(coordinates: worldPolygon!, count: worldPolygon!.count, interiorPolygons: [userPolygon])

The issue is that, because I set canReplaceMapContent() to true it doesn't draw the map anywhere, including the interior polygon which is transparent.

Is there a way to force MKMapView to render the tiles in the area described by the interiorPolygon above?

0

There are 0 best solutions below