--

學習iOS SDK的MKMapView顯示地圖及地圖的標記方法。
參考來源:https://ppt.cc/fkux1x

Peter說。。。最近口罩地圖非常夯。

那麼就以便利商店來為口罩地圖的主題,來MapKit 一下囉。。。。

當然 首先就要先找出一個當前位置(可以居家。公司。或自選)
利用google map找出位置相對應的經緯度

https://www.google.com.tw/maps

在標示位置按右鍵可查經緯度座標

接下來就利用MKMapView顯示地圖,設定範圍。最後加入地圖標記。

import MapKit

import PlaygroundSupport

let mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))

mapView.region = MKCoordinateRegion(center:CLLocationCoordinate2D(latitude:25.042778,longitude: 121.544621),latitudinalMeters:500, longitudinalMeters:500)

PlaygroundPage.current.liveView = mapView

import PlaygroundSupport

let bigBenAnnotation = MKPointAnnotation()

bigBenAnnotation.title = “contractedstore”

bigBenAnnotation.coordinate = CLLocationCoordinate2D( latitude: 25.042778, longitude: 121.544621)

bigBenAnnotation.subtitle = “huaisheng”

mapView.addAnnotation(bigBenAnnotation)

mapView.mapType = MKMapType .hybrid

let jianzhongAnnotation = MKPointAnnotation()

jianzhongAnnotation.title = “contractedstore”

jianzhongAnnotation.coordinate = CLLocationCoordinate2D(latitude: 25.0423, longitude: 121.541696)

jianzhongAnnotation.subtitle = “jianzhong”

mapView.addAnnotation(jianzhongAnnotation)

mapView.pointOfInterestFilter = MKPointOfInterestFilter(including: [.store,.cafe,.park])

為了豐富口罩地圖的周邊,我加入了商店;咖啡館;公園。

增加了位置辨識度,也可以同時來一杯咖啡。。。。
當然。。。也可以去公園散散步。。。。

mask map

--

--