MGLOverlay

@protocol MGLOverlay <MGLAnnotation>

The MGLOverlay 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. Overlays can take the form of a polyline or polygon.

You use overlays to layer more sophisticated content on top of a map view. For example, you could use an overlay to show the boundaries of a national park or trace a bus route along city streets. This SDK defines several concrete classes that conform to this protocol and define standard shapes.

  • A coordinate representing the overlay. (required) (read-only)

    Declaration

    Objective-C

    @property (readonly, nonatomic) CLLocationCoordinate2D coordinate;

    Swift

    var coordinate: CLLocationCoordinate2D { get }
  • The cooordinate rectangle that encompasses the overlay. (required) (read-only)

    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.

    Declaration

    Objective-C

    @property (readonly, nonatomic) MGLCoordinateBounds overlayBounds;

    Swift

    var overlayBounds: MGLCoordinateBounds { get }
  • Returns a Boolean indicating whether the specified rectangle intersects the receiver’s shape.

    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.

    Declaration

    Objective-C

    - (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds;

    Swift

    func intersects(_ overlayBounds: MGLCoordinateBounds) -> Bool

    Parameters

    overlayBounds

    The rectangle to intersect with the receiver’s area.

    Return Value

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