iOS Developer Library

Developer

MapKit Framework Reference MKOverlay Protocol Reference

Options
Deployment Target:

On This Page
Language:

MKOverlay

The MKOverlay protocol defines a specific type of annotation that represents both a point and an area on a map. Overlay objects are essentially data objects that contain the geographic data needed to represent the map area. For example, overlays can take the form of common shapes such as rectangles and circles. They can also describe polygons and other complex shapes. More...

Inheritance


Not Applicable

Import Statement


import MapKit @import MapKit;

Availability


Available in iOS 4.0 and later.
  • The approximate center point of the overlay area. (required) (read-only)

    Declaration

    Swift

    var coordinate: CLLocationCoordinate2D { get }

    Objective-C

    @property(nonatomic, readonly) CLLocationCoordinate2D coordinate

    Discussion

    This point is typically set to the center point of the map’s bounding rectangle. It is used as the anchor point for any callouts displayed for the annotation.

    Import Statement

    import MapKit

    Availability

    Available in iOS 4.0 and later.

  • The projected rectangle that encompasses the overlay. (required) (read-only)

    Declaration

    Swift

    var boundingMapRect: MKMapRect { get }

    Objective-C

    @property(nonatomic, readonly) MKMapRect boundingMapRect

    Discussion

    This property contains the smallest rectangle that completely encompasses the overlay. Implementers of this protocol must set this area when implementing their overlay class, and after setting it, you must not change it. The rectangle should be specified using projected coordinates—that is, coordinates obtained by projecting the globe onto a two-dimensional surface.

    Import Statement

    import MapKit

    Availability

    Available in iOS 4.0 and later.

  • Returns a Boolean indicating whether the specified rectangle intersects the receiver’s shape.

    Declaration

    Swift

    optional func intersectsMapRect(_ mapRect: MKMapRect) -> Bool

    Objective-C

    - (BOOL)intersectsMapRect:(MKMapRect)mapRect

    Parameters

    mapRect

    The rectangle to intersect with the receiver’s area.

    Return Value

    YEStrue if any part of the map rectangle intersects the receiver’s shape or NOfalse if it does not.

    Discussion

    You can implement this method to provide more specific bounds checking for an overlay. If you do not implement it, the bounding rectangle is used to detect intersections.

    Import Statement

    import MapKit

    Availability

    Available in iOS 4.0 and later.

  • Returns a Boolean indicating whether the overlay content replaces the underlying map content.

    Declaration

    Swift

    optional func canReplaceMapContent() -> Bool

    Objective-C

    - (BOOL)canReplaceMapContent

    Return Value

    YEStrue if the map view can skip the loading and drawing of the underlying map tiles or NOfalse if the map tiles should still be drawn.

    Discussion

    The map view uses the return value of this method as a hint to determine whether it should load and render its tiles. If your overlay covers its designated region entirely with opaque content, and effectively replaces the content of underlying map tiles, implement this method and return YEStrue. Doing so alleviates the need for the map to render its tiles.

    If you do not implement this method, or if you return NOfalse from it, the map view continues to load and render its tiles.

    Import Statement

    import MapKit

    Availability

    Available in iOS 7.0 and later.