2010-04-20 13 views
0

目前,我使用mapView.showsUserLocation=YES;作爲顯示iPhone位置的輻射藍色圖標,但不知道如何獲取它後面的座標。locationManager:didUpdateToLocation:fromLocation:vs. mapView.userLocation.location

我試圖locationManager:didUpdateToLocation:fromLocation:self.locationManager = [[[CLLocationManager alloc] init] autorelease]; locationManager.delegate = self; locationManager.distanceFilter=kCLDistanceFilterNone; //record every movement locationManager.desiredAccuracy=kCLLocationAccuracyBest; [locationManager startUpdatingLocation];

我試圖或者都yourGPS=newLocation.coordinate;yourGPS=mapView.userLocation.location.coordinate;didUpdateToLocation,但大多數時候我可以看到藍色氣泡(由mapView.showsUserLocation=YES;控制移動前面的配置,但記錄在didUpdateToLocation中的座標不會改變

我應該在哪裏放yourGPS=mapView.userLocation.location.coordinate;來記錄驅動藍色氣泡的座標?

感謝您的任何信息。

回答

1

這是我在我的應用程序中使用:

- (void)center 
{ 
    NSLog(@"Centering..."); 
    MKCoordinateRegion newRegion; 
    newRegion.center.latitude = mapView.userLocation.location.coordinate.latitude; 
    newRegion.center.longitude = mapView.userLocation.location.coordinate.longitude;   
    newRegion.span.latitudeDelta = 0.112872; 
    newRegion.span.longitudeDelta = 0.109863; 

    [mapView setRegion:newRegion animated:YES]; 
} 
0

由於mapView.showsUserLocation=YES;帶來的內存泄漏,我已經停止使用它,只有使用locationManager得到的座標。它的缺點是我失去了可愛的藍色泡泡,我不知道如何自己做。