A map annotation is a marker (pin) placed on a map to show a specific location.
👉 Example:
A disclosure button is a small info button (ⓘ) on a map pin that:
Reverse geocoding is the process of converting:
👉 Example:
Used to represent a location pin on map.
Custom view for annotations.
Used for reverse geocoding (coordinates → address).
let annotation = MKPointAnnotation()
annotation.title = "Lahore"
annotation.subtitle = "Pakistan"
annotation.coordinate = CLLocationCoordinate2D(latitude: 31.5204,
longitude: 74.3587)
mapView.addAnnotation(annotation)
📍 Pin (Annotation)
├── Title: Lahore
├── Subtitle: Pakistan
└── Coordinates
annotationView.canShowCallout = true
let button = UIButton(type: .detailDisclosure)
annotationView.rightCalloutAccessoryView = button
func mapView(_ mapView: MKMapView,
annotationView view: MKAnnotationView,
calloutAccessoryControlTapped control: UIControl) {
print("Disclosure button tapped")
}
User taps pin
↓
Callout appears (info box)
↓
User taps ⓘ button
↓
More details screen opens
let geocoder = CLGeocoder()
let location = CLLocation(latitude: 31.5204, longitude: 74.3587)
geocoder.reverseGeocodeLocation(location) { placemarks, error in
if let placemark = placemarks?.first {
let city = placemark.locality ?? ""
let country = placemark.country ?? ""
let address = "\(city), \(country)"
print("Address: \(address)")
}
}
Latitude + Longitude
↓
CLGeocoder
↓
Placemark Data
↓
Readable Address (City, Country)
canShowCallout = trueAnnotation = map pin (location marker)
Disclosure button = info button on pin
Reverse geocoding = coordinates → address
Uses:
MKPointAnnotation → pinMKAnnotationView → customizationCLGeocoder → address conversionUsed in:
Open this section to load past papers