问题描述
我正在使用 MKMapView
从 API 加载数据并将位置放置在地图上。当用户滚动地图时,我想从 API 加载其他位置并使用这些位置等填充地图。API 将地图边界作为参数。
我尝试过的:
- (void)mapView:(id)mapView regionDidChangeAnimated:(BOOL)animated {
[self getNewCachesForLiveMap];
}
- (BOOL)currentMapRectIsNew {
NSInteger minZoomLevel = 12;
NSInteger zoom = [self getCurrentZoomLevel];
NSArray *currentAnnotations = [self annotationsInCurrentMapRect];
return currentAnnotations.count == 0 && zoom >= minZoomLevel;
}
// Live Map
- (void)getNewCachesForLiveMap {
BOOL useLiveMap = YES;
if ([self currentMapRectIsNew] && useLiveMap && DEBUG && !self.isMakingLiveMapRequest) {
NSLog(@"***** Live Load *******");
[SVProgressHUD show];
// Load from API
[self loadLocationsForCurrentMapLocation];
}
//self.prevIoUsMapRect = [self currentMapRect];
}
如果我的缩放级别为 12 或更高,这会从 API 正确加载,但它需要我将地图移动到没有加载位置的位置。
我的问题是,有没有更好、更有效的方法来做到这一点?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)