removeAnnotation(_:)
Removes the specified annotation object from the map view.
Declaration
func removeAnnotation(_ annotation: any MKAnnotation)Parameters
- annotation:
The annotation object to remove. This object needs to conform to the Mkannotation protocol.
Discussion
If the annotation is associated with an annotation view, and that view has a reuse identifier, this method removes the annotation view and queues it internally for later reuse. You can retrieve queued annotation views (and associate them with new annotations) using the dequeueReusableAnnotationView(withIdentifier:) method.
Removing an annotation object disassociates it from the map view entirely, preventing the map view from displaying it on the map. Typically, you call this method only when you want to hide or delete a specified annotation.