Skip to content

Commit

Permalink
solution switch demo
Browse files Browse the repository at this point in the history
  • Loading branch information
fasaMaps committed Oct 30, 2023
1 parent 7091966 commit b34bd31
Show file tree
Hide file tree
Showing 111 changed files with 68,883 additions and 28,232 deletions.
4 changes: 4 additions & 0 deletions MapsIndoorsSDK-iOS-Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
4DB9BF222A97758400C4D7FE /* Memory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DB9BF212A97758400C4D7FE /* Memory.swift */; };
4DB9BF252A97761F00C4D7FE /* DisplayMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DB9BF242A97761F00C4D7FE /* DisplayMap.swift */; };
4DB9BF272A97765100C4D7FE /* BaseMapController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DB9BF262A97765100C4D7FE /* BaseMapController.swift */; };
4DD4B0A82AEFD76C00F350D3 /* SolutionSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DD4B0A72AEFD76C00F350D3 /* SolutionSwitch.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -93,6 +94,7 @@
4DB9BF212A97758400C4D7FE /* Memory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Memory.swift; sourceTree = "<group>"; };
4DB9BF242A97761F00C4D7FE /* DisplayMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayMap.swift; sourceTree = "<group>"; };
4DB9BF262A97765100C4D7FE /* BaseMapController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseMapController.swift; sourceTree = "<group>"; };
4DD4B0A72AEFD76C00F350D3 /* SolutionSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SolutionSwitch.swift; sourceTree = "<group>"; };
85CFFC50B8649D6E6055F47F /* Pods-MapsIndoorsSDK-iOS-Examples.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MapsIndoorsSDK-iOS-Examples.release.xcconfig"; path = "Target Support Files/Pods-MapsIndoorsSDK-iOS-Examples/Pods-MapsIndoorsSDK-iOS-Examples.release.xcconfig"; sourceTree = "<group>"; };
A80925BE74AAD8A03986BE1A /* Pods_MapsIndoorsSDK_iOS_Examples.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MapsIndoorsSDK_iOS_Examples.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CC0C3E97BFAF5A9EDEA2A24E /* Pods-MapsIndoorsSDK-iOS-Examples.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MapsIndoorsSDK-iOS-Examples.debug.xcconfig"; path = "Target Support Files/Pods-MapsIndoorsSDK-iOS-Examples/Pods-MapsIndoorsSDK-iOS-Examples.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -151,6 +153,7 @@
4D1F965E2A9DF26F0034CA87 /* ClusteringController.swift */,
4D1F96622A9DF44B0034CA87 /* CustomFloorSelectorController.swift */,
4D1F96642A9DF4B80034CA87 /* Dataset Manager */,
4DD4B0A72AEFD76C00F350D3 /* SolutionSwitch.swift */,
);
path = Advanced;
sourceTree = "<group>";
Expand Down Expand Up @@ -434,6 +437,7 @@
4DB9BF222A97758400C4D7FE /* Memory.swift in Sources */,
4D46522C2AA71216009AD4D6 /* DemoTableViewDataSource.swift in Sources */,
4DB9BEFB2A9769BE00C4D7FE /* AppDelegate.swift in Sources */,
4DD4B0A82AEFD76C00F350D3 /* SolutionSwitch.swift in Sources */,
4D1F96492A9DDA5A0034CA87 /* MyPositionProvider.swift in Sources */,
4DB9BEFD2A9769BE00C4D7FE /* SceneDelegate.swift in Sources */,
4D1F965B2A9DEF460034CA87 /* ToggleLocationsVisibilityController.swift in Sources */,
Expand Down
104 changes: 104 additions & 0 deletions MapsIndoorsSDK-iOS-Examples/Advanced/SolutionSwitch.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//
// SolutionSwitch.swift
// Demos
//
// Created by Christian Wolf Johannsen on 09/01/2023.
// Copyright © 2023 MapsPeople A/S. All rights reserved.
//

import UIKit
import MapsIndoors
import MapsIndoorsCore

class SolutionSwitchController: BaseMapController{
private let pickerView = UIPickerView()
private let solutionName = UILabel()
private let solutions = [
"YOUR_SOLUTION_ID",
"YOUR_SOLUTION_ID_2",
"YOUR_SOLUTION_ID_3",
"YOUR_SOLUTION_ID_4"
]

override func setupController() async {
setupPickerView()
addSolutionLabel()
}

fileprivate func setupPickerView() {
pickerView.delegate = self
pickerView.dataSource = self
pickerView.backgroundColor = .systemGray
view.addSubview(pickerView)
setupPickerViewConstraints()
}

fileprivate func setupPickerViewConstraints() {
pickerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
pickerView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
pickerView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
pickerView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
pickerView.heightAnchor.constraint(equalToConstant: 100)
])
}

func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
let label = (view as? UILabel) ?? UILabel()
label.text = solutions[row]
label.textAlignment = .center
return label
}

fileprivate func addSolutionLabel() {
view.addSubview(solutionName)
solutionName.textColor = .white
solutionName.backgroundColor = .systemGray

solutionName.translatesAutoresizingMaskIntoConstraints = false
solutionName.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
solutionName.topAnchor.constraint(equalTo: view.topAnchor, constant: 150).isActive = true
solutionName.text = MapEngine.APIKey
}
}
// MARK: - UIPickerViewDelegate
extension SolutionSwitchController: UIPickerViewDelegate {
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return solutions[row]
}

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
let selectedSolution = solutions[row]
// update the solution key on app level so `BaseMapController` can update acoordingly
MapEngine.APIKey = selectedSolution
reloadData()
}
}
// MARK: - UIPickerViewDataSource
extension SolutionSwitchController: UIPickerViewDataSource {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return solutions.count
}
}
// MARK: - Data Reload
extension SolutionSwitchController {
func reloadData() {
Task {
startLoadingUI()
try await loadMapsIndoorsSDK()
await moveCameraToBuilding()
stopLoadingUI()
await repopulateTable()
// update the label
solutionName.text = MapEngine.APIKey
}
}

func repopulateTable() async{
await populateDropdownTable()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class DemoSelectorViewController: UITableViewController {
Demo(controllerClass: ClusteringController.self, title: "Clustering and Collisions", description: "Enable/Disable Clustering and Collisions at runtime and provide a custom icon for cluster", sectionTitle: "Advanced"),
Demo(controllerClass: CustomFloorSelectorController.self, title: "Custom Floor Selector", description: "Provide your own custom floor selector, reload controller if no custom floor selector is visible", sectionTitle: "Advanced"),
Demo(controllerClass: DatasetMapController.self, title: "Dataset/Cache", description: "Demo on MapsIndoors cache", sectionTitle: "Advanced"),
Demo(controllerClass: IndoorPositioning.self, title: "Indoor Positioning", description: "Indoor positioning/my location/blue dot", sectionTitle: "Advanced"),
Demo(controllerClass: SolutionSwitchController.self, title: "Solution Switch", description: "Switch a MapsIndoors solution at runtime", sectionTitle: "Advanced"),
]
}

Expand Down
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ target 'MapsIndoorsSDK-iOS-Examples' do
# Comment the next line if you don't want to use dynamic frameworks
#use_frameworks!
# Pods for MapsIndoorsSDK-iOS-Examples
pod 'MapsIndoorsGoogleMaps', '4.2.6'
pod 'MapsIndoorsMapbox', '4.2.6'
pod 'MapsIndoorsGoogleMaps', '4.2.7'
pod 'MapsIndoorsMapbox', '4.2.7'
end

PROJECT_ROOT_DIR = File.dirname(File.expand_path(__FILE__))
Expand Down
34 changes: 17 additions & 17 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PODS:
- MapboxCommon (23.8.3)
- MapboxCoreMaps (10.16.1):
- MapboxCommon (~> 23.8)
- MapboxDirections (2.10.0):
- MapboxDirections (2.11.1):
- Polyline (~> 5.0)
- Turf (~> 2.6.1)
- MapboxMaps (10.16.1):
Expand All @@ -16,22 +16,22 @@ PODS:
- MapboxMobileEvents (= 1.0.10)
- Turf (~> 2.0)
- MapboxMobileEvents (1.0.10)
- MapsIndoors (4.2.6)
- MapsIndoorsCore (4.2.6):
- MapsIndoors (= 4.2.6)
- MapsIndoorsGoogleMaps (4.2.6):
- MapsIndoors (4.2.7)
- MapsIndoorsCore (4.2.7):
- MapsIndoors (= 4.2.7)
- MapsIndoorsGoogleMaps (4.2.7):
- GoogleMaps (= 7.4.0)
- MapsIndoorsCore (= 4.2.6)
- MapsIndoorsMapbox (4.2.6):
- MapboxDirections (= 2.10.0)
- MapsIndoorsCore (= 4.2.7)
- MapsIndoorsMapbox (4.2.7):
- MapboxDirections (= 2.11.1)
- MapboxMaps (= 10.16.1)
- MapsIndoorsCore (= 4.2.6)
- MapsIndoorsCore (= 4.2.7)
- Polyline (5.1.0)
- Turf (2.6.1)

DEPENDENCIES:
- MapsIndoorsGoogleMaps (= 4.2.6)
- MapsIndoorsMapbox (= 4.2.6)
- MapsIndoorsGoogleMaps (= 4.2.7)
- MapsIndoorsMapbox (= 4.2.7)

SPEC REPOS:
trunk:
Expand All @@ -52,16 +52,16 @@ SPEC CHECKSUMS:
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
MapboxCommon: b2c348867dfed7d7a23545e6c2024d712bfda10f
MapboxCoreMaps: c66f482b5ea983cf873122853c4ee94c159bec43
MapboxDirections: a620d78a54312c392323ba211df8ae7dd9a28ab4
MapboxDirections: 31d61b8369d5dde6f6828f72905ab9a7e054cd2c
MapboxMaps: fdbe05e3899abd24f31a7f91789586e44e57f7fc
MapboxMobileEvents: de50b3a4de180dd129c326e09cd12c8adaaa46d6
MapsIndoors: 9b2765c170f0c577cecde71ef72ab29e4d1491ac
MapsIndoorsCore: 6073134c65bea1d6317637f2beb21bf81505bbe1
MapsIndoorsGoogleMaps: d07b62ecff5189ecb05098bbcb50fa862989e500
MapsIndoorsMapbox: 81986386a3266d2c2be5fae98ccce83d0a8cfefe
MapsIndoors: e9b01629876652d2307ccf809a8f9033ec5bfad9
MapsIndoorsCore: 2619fe58ff325b2f673487171955a0f2a58dd3c6
MapsIndoorsGoogleMaps: cd695cb0604010e590b6a3afad21b20b7d47d260
MapsIndoorsMapbox: b542a678a71ad5b1e06ad60b7596bc3fa9b9773c
Polyline: 2a1f29f87f8d9b7de868940f4f76deb8c678a5b1
Turf: 469ce2c3d22e5e8e4818d5a3b254699a5c89efa4

PODFILE CHECKSUM: 4de47ccdc80bf748416fe97678585e31e09acb05
PODFILE CHECKSUM: b288dac64f3251c307de89b3a43841280a8c58e6

COCOAPODS: 1.13.0
34 changes: 17 additions & 17 deletions Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Pods/MapboxDirections/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion Pods/MapboxDirections/Sources/MapboxDirections/Incident.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b34bd31

Please sign in to comment.