mapbox / mapbox/mapbox-maps-ios
Streetlevel data not display while offline
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Xcode version: 14.2
- iOS version: 16.0
- Devices affected: All
- Maps SDK Version: 10.7.0
## 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


Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the reported loading sequence with Apps/Examples/Examples/All Examples/OfflineManagerExample.swift, focusing on the style pack and tile region options for zoom range 0...15. Reproduce the offline case without first zooming online, then verify that street-level details display offline; the issue currently provides no repository test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100