0

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?

Aleksandr
  • 533
  • 1
  • 4
  • 12
  • You might try a `MKMultiPolygon` instead of a `MKPolygon` . Here is a good illustration that shows how you can create exclaves (second MultiPolygon example) https://de.wikipedia.org/wiki/GeoJSON this might even work without messing with boundingMapRect – Gerd Castan Apr 23 '21 at 21:58
  • Thanks for your comment. I actually thought about something like that, but the issue there is that those exclave polygons would have to be calculated dynamically at runtime. And if there's multiple enclave polygons then I think this becomes an intractable problem. – Aleksandr Apr 24 '21 at 00:26

0 Answers0