【发布时间】:2012-09-28 11:42:43
【问题描述】:
如何让我的自定义圆圈叠加层作为子视图实时跟随当前用户位置?我已经设法显示我的圆圈覆盖并到达用户位置的中心,但是当用户移动(gps)时,覆盖保持静止并且不跟随用户。我该如何解决?提前谢谢你..
- (void)viewDidLoad {
[super viewDidLoad];
[self.mapView setRegion:MKCoordinateRegionMake(self.location.coordinate, MKCoordinateSpanMake(0.02, 0.02))];
[self configureOverlay];
[[self locationManager] startUpdatingLocation];
}
在configureOverlay中:
CircleOverlay *overlay = [[CircleOverlay alloc] initWithCoordinate:self.location.coordinate radius:self.radius];
[self.mapView addOverlay:overlay];
GeoQueryAnnotation *annotation = [[GeoQueryAnnotation alloc] initWithCoordinate:self.location.coordinate radius:self.radius];
[self.mapView addAnnotation:annotation];
我也尝试过使用:
CLLocation *location = _locationManager.location;
CLLocationCoordinate2D coordinate = [location coordinate];
并用 self.location.coordinate 替换坐标
任何建议将不胜感激。谢谢您
【问题讨论】:
标签: objective-c ios xcode location overlay