DEPRECATED-mapbox-ios-sdk icon indicating copy to clipboard operation
DEPRECATED-mapbox-ios-sdk copied to clipboard

Not downloading all the needed tiles in beginBackgroundCacheForTileSource:southWest:northEast:minZoom:maxZoom:

Open aleksandr-vin opened this issue 9 years ago • 3 comments

I set up mapView and download tiles as in the example https://github.com/mapbox/mapbox-ios-sdk-offline


float maxDownloadZoom = 19.0;
float minDownloadZoom = 12.0;

mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource];

            mapView.showsUserLocation = NO;
            mapView.zoom = 15.5f;
            mapView.maxZoom = maxDownloadZoom;
            // center the map to the coordinates
            CLLocationCoordinate2D center = CLLocationCoordinate2DMake(59.93248,30.33656);
            mapView.centerCoordinate = center;
            mapView.clusteringEnabled = NO;
            // make map expand to fill screen when rotated
            mapView.autoresizingMask = UIViewAutoresizingFlexibleHeight |
            UIViewAutoresizingFlexibleWidth;

            CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(59.928656913601245,30.327072143554688);
            CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(59.93753684933923, 30.34977436065674);
            [mapView setConstraintsSouthWest:southWest northEast:northEast];

            RMTileCache *cache = [[RMTileCache alloc] initWithExpiryPeriod:0]; // never expires
            mapView.tileCache = cache;

            mapView.delegate = self;

then I download tiles in cache:

[mapView removeAllCachedImages];
mapView.tileCache.backgroundCacheDelegate = self;
                             [mapView.tileCache beginBackgroundCacheForTileSource:mapView.tileSource
                                                                        southWest:southWest
                                                                        northEast:northEast
                                                                          minZoom:minDownloadZoom
                                                                          maxZoom:maxDownloadZoom];

Then I stop my App, turn Airplane mode and run my App again. The result is that not all the tiles are shown on map, different tiles missing in different zoom-s.

I use a 1.6.0 version with #581 fix cherry-picked.

aleksandr-vin avatar Jul 19 '15 20:07 aleksandr-vin

It seems some of the tiles you are trying to download failed. Try to use the backgroundCacheDelegate method - (void)tileCache:(RMTileCache *)tileCache didReceiveError:(NSError *)error whenCachingTile:(RMTile)tile and monitor that/set a breakpoint.

Svantulden avatar Aug 12 '15 06:08 Svantulden

Yes, there are some calls of this delegate. But what should I do to recover these erroneous tiles?

aleksandr-vin avatar Aug 12 '15 07:08 aleksandr-vin

I think retrying tiles is not supported in this library, you probably need to handle the errors yourselves. Maybe make a list of the erroneous tiles from that delegate method and retry them after? Or if the reason of the tiles failing is clear, fix that.

Svantulden avatar Aug 12 '15 07:08 Svantulden