0

I have a MKMapview with lot of polygons added as overlays, To optimize the memory I need to know before adding an overlay if the polygon is inside visible area of the MKMapview

I can even create a whole visible area polygon with mapview all corner coordinates, for example topLeft as below

func topLeftCoordinate() -> CLLocationCoordinate2D {
        return convert(bounds.origin, toCoordinateFrom: self)
}

with all the corner coordinates, I can create a current_visible_area_polygon and I want to check the polygons I add is inside this current_visible_area_polygon.

so it comes down to two questions

  1. Is it possible to check if a polygon is inside another polygon or atleast intersects OR
  2. if a polygon is inside visible maprect
  • 1
    This looks like it may be helpful for you: https://stackoverflow.com/questions/16547575/creating-a-new-mkpolygon-from-two-intersecting-polygons – jnpdx Sep 01 '22 at 23:42

1 Answers1

0

I found the answer to be the following

let mapView: MKMapView
let mkPolygon: MKPolygon

mapView.visibleMapRect.isIntersects(mkPolygon)