Skip to content

Swift CLLocationManager demo,and show userLocation in mapView.

Notifications You must be signed in to change notification settings

JanzTam/MKMapView_swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

MKMapView_swift

Swift CLLocationManager demo,and show userLocation in mapView. Build:Swift 2.0 , Xcode 7.1

tips

if your Xcode project only used Swift,you should set 【Build settings->Embedded Content Contains Swift Code】'no' 'yes'.

Location

asks user permission

add the key to info.plist

NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription

I try ro add one key , however it is not even asks user permission. I add all that it worked.

CLLocationManager

self.locateManage.delegate = self //请求定位权限

if self.locateManage.respondsToSelector(Selector("requestAlwaysAuthorization")) {
     self.locateManage.requestAlwaysAuthorization()
}
        
self.locateManage.desiredAccuracy = kCLLocationAccuracyBest//定位精准度
self.locateManage.startUpdatingLocation()//开始定位

extension

add MKMapView extension

func setCenterCoordinateLevel(centerCoordinate:CLLocationCoordinate2D,var zoomLevel:Double,animated:Bool) 

About

Swift CLLocationManager demo,and show userLocation in mapView.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages