views:

453

answers:

2

For the moment, I use mapView.showsUserLocation=YES; for the radiating blue icon showing the iPhone's position, but do not know how to get the coordinates behind it.

I tried the locationManager:didUpdateToLocation:fromLocation: with the configuration of self.locationManager = [[[CLLocationManager alloc] init] autorelease]; locationManager.delegate = self; locationManager.distanceFilter=kCLDistanceFilterNone; //record every movement locationManager.desiredAccuracy=kCLLocationAccuracyBest; [locationManager startUpdatingLocation];

I tried either both yourGPS=newLocation.coordinate; and yourGPS=mapView.userLocation.location.coordinate; in the didUpdateToLocation, but most of the time I can see the blue bubble (controlled by the mapView.showsUserLocation=YES; moving ahead, but the coordinates recorded in the in the didUpdateToLocation are not changing.

Where should I put yourGPS=mapView.userLocation.location.coordinate; to keep logging the coordinates driving the blue bubble please?

Thanks for any info.

A: 

This is what I use in my app:

- (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];
}
Mike
A: 

Because the mapView.showsUserLocation=YES; brings memory leaks, I have stopped using it, and only use the locationManager to get the coordinates. The disadvantage of it is I lose the lovely blue bubble, which I do not know how to make it myself.

lionfly