当我在地图上加载500个注释时,app在移动地图时会变得迟钝,有没有办法解决这个问题? 当地图被缩放并显示50个注释时很好,但是当缩小以显示所有注释时,应用程序很慢并且在地图中移动时会滞后。
当前代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.annotations = [[NSMutableArray alloc] init];
// Create location manager object
locationManager = [[CLLocationManager alloc] init];
// All results from the location manager
[locationManager setDistanceFilter:kCLDistanceFilterNone];
// Set accuracy
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
// Start updating current location
[mapView setShowsUserLocation:YES];
self.mapView.mapType = MKMapTypeStandard; // also MKMapTypeSatellite or MKMapTypeHybrid
// Start off by default in some city
MKCoordinateRegion newRegion;
newRegion.center.latitude = value1;
newRegion.center.longitude = value2;
newRegion.span.latitudeDelta = value3;
newRegion.span.longitudeDelta = value4;
[self.mapView setRegion:newRegion animated:YES];
[self.mapView addAnnotations:self.annotations]; // --> self.annotations is array with 500 annotations
}