29,030
社区成员
发帖
与我相关
我的任务
分享
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = 10.0f;
[locationManager startUpdatingLocation];
viewcontroller实现代理CLLocationManagerDelegate。
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = newLocation.coordinate.latitude;
theCoordinate.longitude = newLocation.coordinate.longitude;
//[self.mmapView setCenterCoordinate:theCoordinate];
//设定显示范围
MKCoordinateSpan theSpan;
theSpan.latitudeDelta=0.1;
theSpan.longitudeDelta=0.1;
//设置地图显示的中心及范围
MKCoordinateRegion theRegion;
theRegion.center=theCoordinate;
theRegion.span=theSpan;
// 设置地图显示的类型及根据范围进行显示
[self.mmapView setRegion:theRegion];
}
试下这样可以实现你需要的功能不、