我想获取当前位置并在MKMapView上为此坐标设置动画。我获得了当前位置,但是我没有在MKMapView上为此位置设置动画。如何用蓝点动画到当前位置?MKMapView无法按位置设置中心
- (void)viewDidLoad
{
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
self.mapView.delegate = self;
[self.mapView setShowsUserLocation:YES];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyBest;
locationManager.distanceFilter=kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
location = [locationManager location];
CLLocationCoordinate2D coord;
coord.longitude = location.coordinate.longitude;
coord.latitude = location.coordinate.latitude;
lat = coord.latitude;
longt = coord.longitude;
[self.mapView setCenterCoordinate:coord animated:TRUE];
}
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id<MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate] ,250,250);
[mv setRegion:region animated:YES];
}
要通过用户的当前位置.M我正确设置MapView的中心? – 2013-03-22 12:53:01
是的,我想根据用户的当前位置设置mapview中心 – 2013-03-22 13:06:37