Daeng iOS

[IOS/UIKit] KaKao Maps API 현위치 트래킹 본문

IOS/UIKit

[IOS/UIKit] KaKao Maps API 현위치 트래킹

U_Daeng 2022. 8. 13. 03:11

지도에 현재 내 위치를 띄우기 위한 방법이다

1) info.plist를 수정

Privacy - Location When In Use Usage Description : 앱이 사용중일 때만 가져오기 

Privacy - Location Always and When In Use Usage Description : 앱을 사용안해도 항상 가져오기 

 

2) 소스 코드

//지도 불러오기
        mapView = MTMapView(frame: self.subView.bounds)
        if let mapView = mapView {
            //델리게이트 연결
            mapView.delegate = self
            //지도 타입 설정
            mapView.baseMapType = .standard
            //현재 위치 트래킹
            mapView.currentLocationTrackingMode = .onWithoutHeading
            mapView.showCurrentLocationMarker = true
            
            self.view.addSubview(self.subView)
            subView.addSubview(mapView)
        }