iPhone Geliştirme - CLLocationManager vs MapKit

oy
6

i harita üzerinde userLocation göstermek istiyorum ve aynı saat kayıt kullanıcının konumunu çok o yerleri userLocation.location için bir gözlemci ekleyebilir ve kaydetmek için iyi bir fikir olduğunu, YA hala kullanıcı yerini ve kullanımını kaydetmek için CLLocationManager kullanmalıdır mapView.showUserLocation kullanıcının mevcut konumunu (mavi göstergesi) göstermek için? Ben MapKit API tarafından desteklenen varsayılan mavi gösterge göstermek istiyorum.

Ayrıca, burada bir kaba örnek kod:

- (void)viewDidLoad {
    ...

    locationManager = [[CLLocationManager alloc] init]; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    locationManager.distanceFilter = DISTANCE_FILTER_VALUE;
    locationManager.delegate = self; 
    [locationManager startUpdatingLocation];

    myMapView.showUserLocation = YES;
    [myMapView addObserver:self forKeyPath:@userLocation.location options:0 context:nil];

    ...
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    // Record the location information
    // ...
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
    NSLog(@%s begins., __FUNCTION__);

    // Make sure that the location returned has the desired accuracy
    if (newLocation.horizontalAccuracy <= manager.desiredAccuracy)
        return;

    // Record the location information
    // ...
}

Kaputun altında, i MKMapView zamanda kullanıcının mevcut konumunu almak için CLLocationManager kullanır sence? i CLLocationManager ve MapView ikisi de aynı konum hizmetlerini kullanmaya çalışır inanıyoruz çünkü Yani, bu herhangi bir sorun yaratacak? herhangi bir çatışma ve eksikliği doğru bir / gerektiğinde veya mevcut veriler olacak mı?

Oluştur 07/04/2010 saat 07:49
kaynak kullanıcı
Diğer dillerde...                            


1 cevaplar

oy
1

Bu bak SO girdiyi : CLLocationManager örneklerinin tümünü boyunca aynı verileri kullanır, böylece hiçbir çatışma yoktur.

Cevap 07/04/2010 saat 09:07
kaynak kullanıcı

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more