離線地圖或指定地點顯示可透過 MKMapView 與 CLGeocoder 完成。先建立地圖檢視,再以地址字串進行地理編碼,取得座標後放置註解。


ViewController 建立 MKMapView 並設定 delegate。geocodeQuery 使用 CLGeocoder 查詢地址,完成後移除舊註解、調整地圖區域,並加入新的 MapLocation。
MapLocation 遵循 MKAnnotation,提供 title 與 subtitle,用來顯示地點名稱與地址資訊。MKPinAnnotationView 則負責大頭針樣式與動畫。