Instance Method

annotations(in:)

Returns the annotation objects located in the specified map rectangle.

Declaration

func annotations(in mapRect: MKMapRect) -> Set<AnyHashable>

Parameters

mapRect

The portion of the map that you want to search for annotations.

Return Value

The set of annotation objects located in mapRect.

Discussion

This method offers a fast way to retrieve the annotation objects in a particular portion of the map. This method is much faster than doing a linear search of the objects in the annotations property yourself.

Special Considerations

Prior to iOS 7 this method incorrectly did not return instances of MKUserLocation.

See Also

Annotating the Map

var annotations: [MKAnnotation]

The complete list of annotations associated with the receiver.

func addAnnotation(MKAnnotation)

Adds the specified annotation to the map view.

func addAnnotations([MKAnnotation])

Adds an array of annotation objects to the map view.

func removeAnnotation(MKAnnotation)

Removes the specified annotation object from the map view.

func removeAnnotations([MKAnnotation])

Removes an array of annotation objects from the map view.

func view(for: MKAnnotation)

Returns the annotation view associated with the specified annotation object, if any.

var annotationVisibleRect: CGRect

The visible rectangle where annotation views are currently being displayed.

func dequeueReusableAnnotationView(withIdentifier: String)

Returns a reusable annotation view located by its identifier.