天天看點

關于MKMapView&CLLocationManager的一些記錄

顯示自己的位置:

1,在屬性檢查器裡勾選show user location

2,或者通過_mapView.showsUserLocation = YES将屬性設定為YES;

3,self.map.mapType = MKMapTypeStandard;

    self.map.mapType = MKMapTypeSatellite;

    self.map.mapType = MKMapTypeHybrid;

    設定地圖樣式

CLLocationManager使用時的基本設定:

_locationManager.delegate = self;

 _locationManager.desiredAccuracy = kCLLocationAccuracyBest;設定多遠距離重新整理一次位置

開啟定位功能:[_locationManager startUpdatingLocation];

關閉定位功能:[_locationManager stopUpdatingLocation];

設定地圖顯示比率:[_mapView setRegion:region animated:YES];

到某個位置的距離[newLocation  distanceFromLocation:_startPoint];

error.code == kCLErrorDenied判斷重新整理失敗的原因是不是使用者拒絕開啟定位功能 ,未知原因為kCLErrorLocationUnknown

老師為顯示的問題是因為

 if (newLocation.verticalAccuracy < 0 || newLocation.horizontalAccuracy < 0) {

        // invalid accuracy

        return;

    }

    if (newLocation.horizontalAccuracy > 100 || newLocation.verticalAccuracy > 50) {

        // accuracy radius is so large, we don't want to use it

        return;

    }

這個判斷語句,導緻了大頭釘位置标簽未顯示

版權聲明:本文為CSDN部落客「weixin_33815613」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。

原文連結:https://blog.csdn.net/weixin_33815613/article/details/92108015