Mapbox - Receive download progress from TileRegionLoadProgressCallback

58 Views Asked by At

I am trying to update to the v11 Mapbox sdk, my use case is downloading map tiles for offline use. I need to track the progress as the download completes and that is where I am running into issues.

Following the Mapbox documentation, the suggestion is to use TileRegionLoadProgressCallback to track the download progress.

This is my setup:

func updateProgress()->TileRegionLoadProgressCallback{
            
      let callback: TileRegionLoadProgressCallback = {_ in
           print("callback........")
                
        }
       return callback
 }

let tileRegionDownload = tileStore.loadTileRegion(forId: "ID", loadOptions: tileRegionLoadOptions, progress: updateProgress()) { _ in
...

When I run this, the updateProgress function is called only one time when the download finishes. My expectation is that updateProgress would get called as the download is in progress and provide updates as to how much has been downloaded (I am not sure how to actually get the progress either). Previous Mapbox sdk versions provided the ability to get the progress as the download was in progress and that is what I was using until I was attempting to use the latest version of the sdk.

In version 10.X of the sdk I could do something like this:

let tileRegionDownload = tileStore!.loadTileRegion(forId: "ID",
                                                              loadOptions: tileRegionLoadOptions) { [weak self] (progress) in
                
     DispatchQueue.main.async {
                    
          print("message: completedResourceCount: \(progress.completedResourceCount) progress.requiredResourceCount: \((progress.requiredResourceCount))")
                    
     }
}

For reference I am using:

Mapbox Common SDK v24.0.0(e4b15d2aa)

Mapbox Core Maps SDK v11.0.0(d78372e7a5)

Any suggestions for what I am missing?

0

There are 0 best solutions below