0

我有一个包含 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];
            }
        }

但是他们加载了太多的点,我的问题是我不想加载所有的点,因为每次我都必须使用算法来排序。

4

0 回答 0