'Offline Satellite Map is loading too much slow on iOS

We are working on an iOS mobile application with MapBox SDK for offline maps.

We are currently facing two main issues with iOS MapBox SDK.

  1. We are able to download the maps successfully. The app is working great with small region maps, but if we download large offline regions/pack, the same code is taking too much time to load the big map. Specially for Mapbox satellite street map with more than 2GB size. But it is not happening in Android.

  2. Because the offline map is huge in size, if we try to remove the offline pack, it takes too much time and does not allow to download further maps, because of tile limit count exceeds.

Can you please guide us how can we make this app better to work with offline maps in iOS?

We have followed all the documentation for iOS provided by MapBox SDK but cannot tweak the performance in case of large offline packs.

Source code for loading Offline pack in iOS.

if (packs.count) > 0{

            for i in 0..<(packs.count){

                let dict = NSKeyedUnarchiver.unarchiveObject(with: packs[i].context ) as! [String: Any]

                if (map.mapGenID) == "\(dict["mapID"]!)" {
                    index = i
                    break
                }
            }


            if let tiles = MGLOfflineStorage.shared.packs?[index].region as? MGLTilePyramidOfflineRegion{

                if let currentStyle = SharedMapView.shared().mapView.styleURL {

                    if !currentStyle.absoluteString.isEqual(tiles.styleURL.absoluteString) {

                        SharedMapView.shared().mapView.styleURL =  tiles.styleURL
                        SVProgressHUD.show(withStatus: "Loading Map ..")


                    }
                }else{

                    SharedMapView.shared().mapView.styleURL =  tiles.styleURL
                }



                    offlineMapBounds = tiles.bounds
                    SharedMapView.shared().mapView.minimumZoomLevel = tiles.minimumZoomLevel
                    SharedMapView.shared().mapView.maximumZoomLevel = tiles.maximumZoomLevel
                    SharedMapView.shared().mapView.setVisibleCoordinateBounds(offlineMapBounds, edgePadding: UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12), animated: true)



            }
        }

Source code For Delete offline pack.

MGLOfflineStorage.shared.removePack(self.packs[indexPath.row], withCompletionHandler: { (err) in

                    if (err == nil) { //Pack Deleted 

                     // Delete from Table row   

                    }

                })

We want to load the big offline maps quickly as it is working perfectly with small maps.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source