16000 の注釈を含むデータベースがあります。ユーザーがズームアウトしているときに、ロードされたポイントが多すぎて、ポイントがオーバーラップします。コードを含むフィルターを見つけましたが、すべてをロードしてからフィルタリングするのではなく、SQL からのみいくつかのポイントをロードしたいと考えています。iOSまたは他のソリューションにストアドプロシージャがあるかどうかはわかりません。
これは私のコードです
iphoneScaleFactorLatitude = 3.3;
float iphoneScaleFactorLongitude = 6.38;
float latDelta = self.mapView.region.span.latitudeDelta/iphoneScaleFactorLatitude;
float longDelta = self.mapView.region.span.longitudeDelta/iphoneScaleFactorLongitude;
NSMutableArray *shopsToShow = [[NSMutableArray alloc] initWithCapacity:0];
for (int i=0; i<[placesToFilter count]; i++) {
MKPointAnnotation *checkingLocation = [placesToFilter objectAtIndex:i];
CLLocationDegrees latitude = [checkingLocation coordinate].latitude;
CLLocationDegrees longitude = [checkingLocation coordinate].longitude;
bool found=FALSE;
for (MKPointAnnotation *tempPlacemark in shopsToShow) {
if(fabs([tempPlacemark coordinate].latitude-latitude) < latDelta &&
fabs([tempPlacemark coordinate].longitude-longitude) <longDelta ){
[self.mapView removeAnnotation:checkingLocation];
found = TRUE;
break;
}
}
if (!found){
[shopsToShow addObject:checkingLocation];
[self.mapView addAnnotation:checkingLocation];
}
}
しかし、それらはあまりにも多くのポイントをロードします。私の問題は、ソートにアルゴリズムを使用する必要があるため、すべてのポイントをロードしたくないということです。