mapbox / mapbox-maps-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and Metal
https://www.mapbox.com/mapbox-mobile-sdk
Other
481 stars 157 forks source link

Streetlevel data not display while offline #1894

Open Ashish31081309 opened 1 year ago

Ashish31081309 commented 1 year ago

Environment

Observed behaviour and steps to reproduce

 {
    guard let tileStore = tileStore else {
        print("tileStore missing")
        preconditionFailure()
    }
    let dispatchGroup = DispatchGroup()
    guard let url = MapboxDownloadManager.shared.styleURL, let styleURI = StyleURI(url: url) else {
        return
    }
    let accessToken = ResourceOptionsManager.default.resourceOptions.accessToken
    offlineManager = OfflineManager(resourceOptions: ResourceOptions(accessToken: accessToken,
                                                                         tileStore: tileStore))
    // 1. Create style package with loadStylePack() call.
    let stylePackLoadOptions = StylePackLoadOptions(glyphsRasterizationMode: .allGlyphsRasterizedLocally,
                                                    metadata: ["tag": "my-outdoors-style-pack"],
                                                    acceptExpired: true)!

    dispatchGroup.enter()
    _ = offlineManager?.loadStylePack(for: styleURI, loadOptions: stylePackLoadOptions) { [weak self] progress in
        // These closures do not get called from the main thread. In this case
        DispatchQueue.main.async {
            print(" progress completedResourceCount/ - requiredResourceCount \(progress.completedResourceCount) / \(progress.requiredResourceCount)")
            print("StylePack = \(progress)")
        }

    } completion: { [weak self] result in
        DispatchQueue.main.async {
            defer {
                dispatchGroup.leave()
            }
            switch result {
            case let .success(stylePack):
                print("StylePack = \(stylePack)")
            case let .failure(error):
                print("stylePack download Error = \(error)")
            }
        }
    }

    // 2. Create an offline region with tiles for the outdoors style
    let outdoorsOptions = TilesetDescriptorOptions(styleURI: styleURI.rawValue, minZoom: UInt8(minZoom), maxZoom: UInt8(maxZoom), stylePack: stylePackLoadOptions)

    guard let outdoorsDescriptor = offlineManager?.createTilesetDescriptor(for: outdoorsOptions) else {
        print("outdoorsDescriptor -> missing")
        return
    }
    // Load the tile region
    let tileRegionLoadOptions = TileRegionLoadOptions(
        geometry: .point(Point(coord)),
        descriptors: [outdoorsDescriptor],
        metadata: userInfo,
        acceptExpired: true)!

    // Use the the default TileStore to load this region. You can create
    // custom TileStores are are unique for a particular file path, i.e.
    // there is only ever one TileStore per unique path.
    dispatchGroup.enter()
    _ = tileStore.loadTileRegion(forId: tileRegionId, loadOptions: tileRegionLoadOptions) { progress in
        // These closures do not get called from the main thread. In this case
        // we're updating the UI, so it's important to dispatch to the main
        // queue.
        DispatchQueue.main.async {
            // Update the progress bar
            print("Download progress : ")
            print(Float(progress.completedResourceCount) / Float(progress.requiredResourceCount))
        }
    } completion: { result in
        DispatchQueue.main.async {
            defer {
                dispatchGroup.leave()
            }

            switch result {
            case let .success(tileRegion):
                print("tileRegion = \(tileRegion)")

                print(" tileRegion progress completedResourceCount/ - requiredResourceCount \(tileRegion.completedResourceCount) / \(tileRegion.requiredResourceCount)")

                self.showDownloadedRegions()

            case let .failure(error):
                print("tileRegion download Error = \(error)")

            }
        }
    }
    // Wait for both downloads before moving to the next state
    dispatchGroup.notify(queue: .main) {
        print("notify download complete")
    }
}

Expected behaviour

I downloaded the style and tiles and it's working fine but while offline zoom-in street-level details were not getting displayed... [zoomRange: 0...15]

Notes / preliminary analysis

if a user is online and zoom-in then streel level details cache offline but without zoom-in, street-level data is not getting displayed offline

Additional links and references

I take the code reference from below Mapbox example: https://github.com/mapbox/mapbox-maps-ios/blob/main/Apps/Examples/Examples/All%20Examples/OfflineManagerExample.swift

details_map details_missing

pjleonard37 commented 1 year ago

Hi @Ashish31081309 --

Thanks for reporting. I ran this example on our latest version v10.10.1 and I was not able to replicate the issue you are reporting.

To continue the investigation can you: 1.) Upgrade to a more recent version of the SDK and try again 2.) Share the Style you are working with