Protocol

MKOverlay

An interface for associating content with a specific map region.

Overview

Overlay objects are data objects that define the geographic data to cover. MapKit defines several concrete classes that adopt this protocol and define standard shapes such as rectangles, circles, and polygons. You might use overlays to define the geographic boundaries of a national park or trace a bus route along city streets. You add an overlay to your map view by calling its add(_:) method or any other map view method for adding overlays to the map. When the overlay's region intersects the visible portion of the map, the map view calls the mapView(_:rendererFor:) method of its delegate to obtain the renderer object responsible for drawing the overlay.

If you add an overlay to a map view as an annotation, instead of adding it as an overlay, the map view treats your overlay as an annotation. Specifically, it displays your overlay only when its coordinate is in the visible map region, rather than displaying the overlay when any portion of its covered area is visible.

Topics

Describing the Overlay Geometry

var coordinate: CLLocationCoordinate2D

The approximate center point of the overlay area.

Required.

var boundingMapRect: MKMapRect

The projected rectangle that encompasses the overlay.

Required.

Determining Map Intersections

func intersects(MKMapRect)

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

Optimizing Map Rendering

func canReplaceMapContent()

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

Relationships

Inherits From

See Also

Annotations and Overlays

class MKPlacemark

A user-friendly description of a location on the map.

protocol MKAnnotation

An interface for associating your content with a specific map location.

class MKAnnotationView

The visual representation of one of your annotation objects.

class MKOverlayRenderer

The shared infrastructure used to draw overlays on the map surface.

MapKit Annotations

Use these annotation objects as-is in your maps.

MapKit Overlays

Use these overlays as-is in your maps.