Skip to content

Commit

Permalink
Remove offline mode from MapRootController - SSDK-667
Browse files Browse the repository at this point in the history
- Remove `--offline` launch argument flag
  • Loading branch information
aokj4ck committed Apr 25, 2024
1 parent 1e9d62f commit 1ab3080
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions Sources/Demo/MapRootController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,13 @@ class MapRootController: UIViewController {
let panelController = MapboxPanelController(rootViewController: searchController)
addChild(panelController)

if ProcessInfo.processInfo.arguments.contains("--offline") {
enableOfflineSearch()
}

// Enabling jp/ja search options for testing Japanese Address Search.
// Setting Japanese into the list of preferred languages is a way to activate it.
if Locale.preferredLanguages.contains(where: { $0.contains("ja") }) {
searchController.searchOptions = SearchOptions(countries: ["jp"], languages: ["ja"])
}
}

func enableOfflineSearch() {
let engine = searchController.searchEngine

engine.setOfflineMode(.enabled) {
let descriptor = SearchOfflineManager.createDefaultTilesetDescriptor()

let dcLocation = NSValue(mkCoordinate: CLLocationCoordinate2D(
latitude: 38.89992081005698,
longitude: -77.03399849939174
))

guard let options = MapboxCommon.TileRegionLoadOptions.build(
geometry: Geometry(point: dcLocation),
descriptors: [descriptor],
acceptExpired: true
) else {
assertionFailure()
return
}

_ = engine.offlineManager.tileStore.loadTileRegion(id: "dc", options: options, progress: nil) { result in
switch result {
case .success(let region):
assert(region.id == "dc")
case .failure(let error):
print(error.localizedDescription)
assertionFailure()
}
}
}
}

let locationManager = CLLocationManager()

override func viewDidAppear(_ animated: Bool) {
Expand Down

0 comments on commit 1ab3080

Please sign in to comment.