mapbox / DEPRECATED-mapbox-ios-sdk

REPLACED – use https://www.mapbox.com/ios-sdk instead
https://github.com/mapbox/mapbox-gl-native
Other
323 stars 8 forks source link

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

Open aleksandr-vin opened 9 years ago

aleksandr-vin commented 9 years ago

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.

Svantulden commented 9 years ago

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.

aleksandr-vin commented 9 years ago

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

Svantulden commented 9 years ago

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.