關於MKMapView&CLLocationManager的一些記錄

顯示本身的位置:
spa

1,在屬性檢查器裏勾選show user locationcode

2,或者經過_mapView.showsUserLocation = YES將屬性設置爲YES;it

3,self.map.mapType = MKMapTypeStandard;io

    self.map.mapType = MKMapTypeSatellite;map

    self.map.mapType = MKMapTypeHybrid;im

    設置地圖樣式
地圖

CLLocationManager使用時的基本設置:error

_locationManager.delegate = self;樣式

 _locationManager.desiredAccuracy = kCLLocationAccuracyBest;設置多遠距離刷新一次位置top

開啓定位功能:[_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;

    }

這個判斷語句,致使了大頭釘位置標籤未顯示

相關文章
相關標籤/搜索