
A map annotation is a marker (pin) placed on a map to show a specific location.
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 view and download past papers
Click on Show Past Papers to load available exam papers.