@mapsindoors/react-native-maps-indoors-mapbox 2.6.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/android/build.gradle +17 -70
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsPackage.java +69 -18
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +5 -1
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +5 -2
- package/android/src/main/java/com/mapsindoorsrn/core/MPDisplayRuleModule.java +5 -1
- package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +5 -1
- package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +4 -1
- package/android/src/main/java/com/mapsindoorsrn/core/UtilsModule.java +4 -1
- package/ios/core/DirectionsRendererBridge.m +5 -0
- package/ios/core/DirectionsRendererModule.swift +92 -72
- package/ios/core/DirectionsServiceBridge.m +1 -1
- package/ios/core/DirectionsServiceModule.swift +44 -51
- package/ios/core/IconStopUrl.swift +1 -1
- package/ios/core/MPDisplayRuleModule.swift +208 -210
- package/ios/core/MapControlModule.swift +284 -216
- package/ios/core/MapsIndoorsData.swift +48 -49
- package/ios/core/MapsIndoorsModule.swift +46 -52
- package/ios/core/RCMapView.swift +1 -1
- package/ios/core/ReactPositionProvider.swift +1 -2
- package/ios/core/RouteIcon.swift +6 -6
- package/ios/core/UtilsModule.swift +37 -42
- package/ios/core/helpers.swift +16 -11
- package/package.json +10 -1
- package/react-native-maps-indoors-mapbox.podspec +3 -3
- package/specs/MapsIndoorsViewNativeComponent.ts +10 -0
- package/specs/NativeDirectionsRendererModule.ts +23 -0
- package/specs/NativeDirectionsServiceModule.ts +22 -0
- package/specs/NativeMPDisplayRuleModule.ts +155 -0
- package/specs/NativeMapControlModule.ts +62 -0
- package/specs/NativeMapsIndoorsModule.ts +43 -0
- package/specs/NativeUtilsModule.ts +21 -0
- package/src/core/MPDirectionsRenderer.ts +15 -0
- package/src/core/MPDirectionsService.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapsIndoors
|
|
2
|
-
import MapsIndoorsCore
|
|
3
2
|
import MapsIndoorsCodable
|
|
3
|
+
import MapsIndoorsCore
|
|
4
4
|
import React
|
|
5
5
|
|
|
6
6
|
protocol LiveDataDelegate {
|
|
@@ -9,7 +9,7 @@ protocol LiveDataDelegate {
|
|
|
9
9
|
|
|
10
10
|
class MapsIndoorsData {
|
|
11
11
|
public static var sharedInstance: MapsIndoorsData = MapsIndoorsData()
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
public static func reset() {
|
|
14
14
|
sharedInstance = MapsIndoorsData()
|
|
15
15
|
}
|
|
@@ -36,7 +36,7 @@ class MapsIndoorsData {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
lazy var allEvents: [String] = {
|
|
39
|
-
var allEventNames: [String] = Event.allCases.map{$0.rawValue}
|
|
39
|
+
var allEventNames: [String] = Event.allCases.map { $0.rawValue }
|
|
40
40
|
return allEventNames
|
|
41
41
|
}()
|
|
42
42
|
}
|
|
@@ -60,15 +60,14 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
60
60
|
var consumeChangeLocation: Bool = false
|
|
61
61
|
|
|
62
62
|
var respondToDidTapInfoWindow: Bool = false
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
var respondToCameraEvents: Bool = false
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
var zoom: Float = 0.0
|
|
67
67
|
|
|
68
68
|
init(eventEmitter: RCTEventEmitter) {
|
|
69
69
|
self.eventEmitter = eventEmitter
|
|
70
70
|
}
|
|
71
|
-
|
|
72
71
|
|
|
73
72
|
private func sendEvent(event: MapsIndoorsData.Event, body: [String: Any?]) {
|
|
74
73
|
eventEmitter.sendEvent(withName: event.rawValue, body: body)
|
|
@@ -78,41 +77,41 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
78
77
|
let rounded = round(number)
|
|
79
78
|
return abs(number - rounded) < tolerance
|
|
80
79
|
}
|
|
81
|
-
|
|
80
|
+
|
|
82
81
|
// MPMapControlDelegate:
|
|
83
|
-
|
|
82
|
+
|
|
84
83
|
func didChangeCameraPosition() -> Bool {
|
|
85
|
-
if
|
|
84
|
+
if respondToCameraEvents {
|
|
86
85
|
sendEvent(event: .cameraEvent, body: ["event": 5])
|
|
87
86
|
}
|
|
88
|
-
|
|
87
|
+
|
|
89
88
|
if let mapControl = MapsIndoorsData.sharedInstance.mapView?.getMapControl() {
|
|
90
89
|
let z = mapControl.mapsIndoorsZoom
|
|
91
|
-
if z != zoom && (z.isLess(than: zoom-0.02) || zoom.isLess(than: z-0.02) || self.isCloseToWholeNumber(z, tolerance: 0.02)) {
|
|
90
|
+
if z != zoom && (z.isLess(than: zoom - 0.02) || zoom.isLess(than: z - 0.02) || self.isCloseToWholeNumber(z, tolerance: 0.02)) {
|
|
92
91
|
zoom = z
|
|
93
92
|
MapsIndoorsData.sharedInstance.floorSelector?.onZoomChanged(zoom: zoom)
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
|
-
|
|
97
|
-
return false
|
|
95
|
+
|
|
96
|
+
return false
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
func cameraIdle() -> Bool {
|
|
101
|
-
if
|
|
100
|
+
if respondToCameraEvents {
|
|
102
101
|
sendEvent(event: .cameraEvent, body: ["event": 7])
|
|
103
102
|
}
|
|
104
|
-
return false
|
|
103
|
+
return false
|
|
105
104
|
}
|
|
106
|
-
|
|
105
|
+
|
|
107
106
|
func cameraWillMove() -> Bool {
|
|
108
|
-
if
|
|
107
|
+
if respondToCameraEvents {
|
|
109
108
|
sendEvent(event: .cameraEvent, body: ["event": 5])
|
|
110
109
|
}
|
|
111
|
-
return false
|
|
110
|
+
return false
|
|
112
111
|
}
|
|
113
|
-
|
|
112
|
+
|
|
114
113
|
func didTap(coordinate: MPPoint) -> Bool {
|
|
115
|
-
if
|
|
114
|
+
if respondToTap {
|
|
116
115
|
sendEvent(event: .onMapClick, body: ["point": toJSON(coordinate)])
|
|
117
116
|
return consumeTap
|
|
118
117
|
}
|
|
@@ -120,7 +119,7 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
func didTapIcon(location: MPLocation) -> Bool {
|
|
123
|
-
if
|
|
122
|
+
if respondToTapIcon {
|
|
124
123
|
sendEvent(event: .onMarkerClick, body: ["locationId": location.locationId])
|
|
125
124
|
return consumeTapIcon
|
|
126
125
|
}
|
|
@@ -128,39 +127,39 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
func didChange(floorIndex: Int) -> Bool {
|
|
131
|
-
if
|
|
130
|
+
if respondToDidChangeFloorIndex {
|
|
132
131
|
sendEvent(event: .onFloorUpdate, body: ["floorIndex": floorIndex])
|
|
133
132
|
}
|
|
134
|
-
|
|
133
|
+
|
|
135
134
|
MapsIndoorsData.sharedInstance.floorSelector?.onFloorSelectionChanged(newFloor: NSNumber(value: floorIndex))
|
|
136
135
|
return false
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
func didChange(selectedVenue: MPVenue?) -> Bool {
|
|
140
|
-
if
|
|
141
|
-
sendEvent(event: .onVenueFoundAtCameraTarget, body: ["venue": selectedVenue.map{ toJSON(MPVenueCodable(withVenue:($0))) }])
|
|
139
|
+
if respondToDidChangeVenue {
|
|
140
|
+
sendEvent(event: .onVenueFoundAtCameraTarget, body: ["venue": selectedVenue.map { toJSON(MPVenueCodable(withVenue: ($0))) }])
|
|
142
141
|
}
|
|
143
142
|
return false
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
func didChange(selectedBuilding: MPBuilding?) -> Bool {
|
|
147
|
-
if
|
|
148
|
-
sendEvent(event: .onBuildingFoundAtCameraTarget, body: ["building": selectedBuilding.map{ toJSON(MPBuildingCodable(withBuilding:($0))) }])
|
|
146
|
+
if respondToDidChangeBuilding {
|
|
147
|
+
sendEvent(event: .onBuildingFoundAtCameraTarget, body: ["building": selectedBuilding.map { toJSON(MPBuildingCodable(withBuilding: ($0))) }])
|
|
149
148
|
}
|
|
150
149
|
MapsIndoorsData.sharedInstance.floorSelector?.building = selectedBuilding
|
|
151
150
|
return false
|
|
152
151
|
}
|
|
153
152
|
|
|
154
153
|
func didChange(selectedLocation: MPLocation?) -> Bool {
|
|
155
|
-
if
|
|
156
|
-
sendEvent(event: .onLocationSelected, body: ["location": selectedLocation.map{ toJSON(MPLocationCodable(withLocation:($0))) }])
|
|
154
|
+
if respondToDidChangeLocation {
|
|
155
|
+
sendEvent(event: .onLocationSelected, body: ["location": selectedLocation.map { toJSON(MPLocationCodable(withLocation: ($0))) }])
|
|
157
156
|
return consumeChangeLocation
|
|
158
157
|
}
|
|
159
158
|
return false
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
func didTapInfoWindow(location: MPLocation) -> Bool {
|
|
163
|
-
if
|
|
162
|
+
if respondToDidTapInfoWindow {
|
|
164
163
|
sendEvent(event: .onInfoWindowClick, body: ["locationId": location.locationId])
|
|
165
164
|
}
|
|
166
165
|
return false
|
|
@@ -173,7 +172,7 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
173
172
|
return
|
|
174
173
|
}
|
|
175
174
|
|
|
176
|
-
sendEvent(event: .onLiveLocationUpdate, body: [
|
|
175
|
+
sendEvent(event: .onLiveLocationUpdate, body: ["location": toJSON(MPLocationCodable(withLocation: (location)))])
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
// MPFloorSelectorDelegate:
|
|
@@ -184,40 +183,38 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
184
183
|
}
|
|
185
184
|
|
|
186
185
|
func floorSelector(method: FloorSelector.Event, args: [String: Any]) {
|
|
187
|
-
let body = try! ["method": method.rawValue].merging(args, uniquingKeysWith: { _,_ in throw MPError.unknownError })
|
|
186
|
+
let body = try! ["method": method.rawValue].merging(args, uniquingKeysWith: { _, _ in throw MPError.unknownError })
|
|
188
187
|
|
|
189
188
|
sendEvent(event: .floorSelector, body: body)
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
|
|
193
|
-
|
|
194
192
|
class FloorSelector: UIView, MPCustomFloorSelector {
|
|
195
|
-
|
|
196
193
|
enum Event: String, CaseIterable, RawRepresentable {
|
|
197
194
|
case show
|
|
198
195
|
case setList
|
|
199
196
|
case setUserPositionFloor
|
|
200
197
|
// TODO: the rest are not implemented since they are not available from the MPCustomFloorSelector protocol, and are not implemented in flutter
|
|
201
|
-
// case setSelectedFloor
|
|
198
|
+
// case setSelectedFloor
|
|
202
199
|
case setSelectedFloorByFloorIndex
|
|
203
200
|
case zoomLevelChanged
|
|
204
201
|
}
|
|
205
|
-
|
|
202
|
+
|
|
206
203
|
lazy var allEvents: [String] = {
|
|
207
|
-
var allEventNames: [String] = Event.allCases.map{$0.rawValue}
|
|
204
|
+
var allEventNames: [String] = Event.allCases.map { $0.rawValue }
|
|
208
205
|
return allEventNames
|
|
209
206
|
}()
|
|
210
207
|
|
|
211
208
|
var building: MapsIndoors.MPBuilding? {
|
|
212
209
|
didSet {
|
|
213
|
-
if
|
|
210
|
+
if oldValue?.buildingId != building?.buildingId { onShow() }
|
|
214
211
|
}
|
|
215
212
|
}
|
|
216
213
|
var latestBuilding: MapsIndoors.MPBuilding?
|
|
217
214
|
var delegate: MapsIndoors.MPFloorSelectorDelegate?
|
|
218
215
|
|
|
219
216
|
var hide: Bool = false
|
|
220
|
-
|
|
217
|
+
|
|
221
218
|
var floorIndex: NSNumber?
|
|
222
219
|
|
|
223
220
|
var autoFloorChange = true
|
|
@@ -245,15 +242,18 @@ class FloorSelector: UIView, MPCustomFloorSelector {
|
|
|
245
242
|
|
|
246
243
|
func onShow() {
|
|
247
244
|
DispatchQueue.main.async {
|
|
248
|
-
if
|
|
245
|
+
if !self.hide && self.building == nil && self.building === self.latestBuilding {
|
|
249
246
|
return
|
|
250
247
|
}
|
|
251
248
|
if let building = self.building {
|
|
252
|
-
self.listenerDelegate.floorSelector(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
249
|
+
self.listenerDelegate.floorSelector(
|
|
250
|
+
method: .setList,
|
|
251
|
+
args: [
|
|
252
|
+
"list": toJSON(
|
|
253
|
+
building.floors?.values.sorted(by: { (floor1, floor2) -> Bool in
|
|
254
|
+
return floor1.floorIndex!.intValue < floor2.floorIndex!.intValue
|
|
255
|
+
}).map { MPFloorCodable(withFloor: $0) })
|
|
256
|
+
])
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
self.listenerDelegate.floorSelector(method: .show, args: ["show": true, "animated": true])
|
|
@@ -261,10 +261,10 @@ class FloorSelector: UIView, MPCustomFloorSelector {
|
|
|
261
261
|
self.hide = false
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
|
|
264
|
+
|
|
265
265
|
func onHide() {
|
|
266
266
|
DispatchQueue.main.async {
|
|
267
|
-
if
|
|
267
|
+
if self.hide {
|
|
268
268
|
return
|
|
269
269
|
}
|
|
270
270
|
self.listenerDelegate.floorSelector(method: .show, args: ["show": false, "animated": true])
|
|
@@ -278,11 +278,10 @@ class FloorSelector: UIView, MPCustomFloorSelector {
|
|
|
278
278
|
self.listenerDelegate.floorSelector(method: .setUserPositionFloor, args: ["floor": floorIndex])
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
func onZoomChanged(zoom: Float) {
|
|
283
283
|
DispatchQueue.main.async {
|
|
284
284
|
self.listenerDelegate.floorSelector(method: .zoomLevelChanged, args: ["zoom": Double(zoom)])
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
|
|
288
287
|
}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import MapsIndoors
|
|
3
|
-
import MapsIndoorsCore
|
|
4
3
|
import MapsIndoorsCodable
|
|
5
|
-
|
|
4
|
+
import MapsIndoorsCore
|
|
6
5
|
import React
|
|
7
6
|
|
|
8
7
|
@objc(MapsIndoorsModule)
|
|
9
8
|
public class MapsIndoorsModule: NSObject {
|
|
10
|
-
|
|
11
|
-
@objc public static func requiresMainQueueSetup() -> Bool {return false}
|
|
9
|
+
@objc public static func requiresMainQueueSetup() -> Bool { return false }
|
|
12
10
|
|
|
13
11
|
@objc public func test() {
|
|
14
|
-
print("%@.test()", String(describing: self))
|
|
12
|
+
print("%@.test()", String(describing: self))
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
private var positionProvider: ReactPositionProvider?
|
|
18
16
|
|
|
19
17
|
@objc(loadMapsIndoors:optionalStrings:resolver:rejecter:)
|
|
20
|
-
func loadMapsIndoors(apiKey: String, optionalStrings: [String]?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock)
|
|
18
|
+
func loadMapsIndoors(apiKey: String, optionalStrings: [String]?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
21
19
|
Task {
|
|
22
20
|
do {
|
|
23
|
-
if
|
|
21
|
+
if optionalStrings != nil {
|
|
24
22
|
try await MPMapsIndoors.shared.load(apiKey: apiKey, venueIds: optionalStrings!)
|
|
25
|
-
}else {
|
|
23
|
+
} else {
|
|
26
24
|
try await MPMapsIndoors.shared.load(apiKey: apiKey)
|
|
27
25
|
}
|
|
28
26
|
MapsIndoorsData.sharedInstance.isInitialized = true
|
|
@@ -37,9 +35,11 @@ public class MapsIndoorsModule: NSObject {
|
|
|
37
35
|
Task {
|
|
38
36
|
let venues = await MPMapsIndoors.shared.venues()
|
|
39
37
|
|
|
40
|
-
return resolve(
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
return resolve(
|
|
39
|
+
toJSON(
|
|
40
|
+
venues.map {
|
|
41
|
+
MPVenueCodable(withVenue: $0)
|
|
42
|
+
}))
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -47,9 +47,11 @@ public class MapsIndoorsModule: NSObject {
|
|
|
47
47
|
Task {
|
|
48
48
|
let buildings = await MPMapsIndoors.shared.buildings()
|
|
49
49
|
|
|
50
|
-
return resolve(
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
return resolve(
|
|
51
|
+
toJSON(
|
|
52
|
+
buildings.map {
|
|
53
|
+
MPBuildingCodable(withBuilding: $0)
|
|
54
|
+
}))
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -57,18 +59,22 @@ public class MapsIndoorsModule: NSObject {
|
|
|
57
59
|
Task {
|
|
58
60
|
let categories = await MPMapsIndoors.shared.categories()
|
|
59
61
|
|
|
60
|
-
return resolve(
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
return resolve(
|
|
63
|
+
toJSON(
|
|
64
|
+
categories.map {
|
|
65
|
+
MPDataFieldCodable(withDataField: $0)
|
|
66
|
+
}))
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
@objc public func getLocations(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
67
71
|
Task {
|
|
68
72
|
let locations = await MPMapsIndoors.shared.locationsWith(query: MPQuery(), filter: MPFilter())
|
|
69
|
-
return resolve(
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
return resolve(
|
|
74
|
+
toJSON(
|
|
75
|
+
locations.map {
|
|
76
|
+
MPLocationCodable(withLocation: $0)
|
|
77
|
+
}))
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
|
|
@@ -132,7 +138,7 @@ public class MapsIndoorsModule: NSObject {
|
|
|
132
138
|
return doReject(reject, message: "getMapStyles: Got no styles")
|
|
133
139
|
}
|
|
134
140
|
|
|
135
|
-
let mapStyles = styles.map({ MPMapStyleCodable(withMapStyle
|
|
141
|
+
let mapStyles = styles.map({ MPMapStyleCodable(withMapStyle: $0) })
|
|
136
142
|
return resolve(toJSON(mapStyles))
|
|
137
143
|
}
|
|
138
144
|
|
|
@@ -145,7 +151,6 @@ public class MapsIndoorsModule: NSObject {
|
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
@objc public func getLocationsAsync(_ query: String, filter: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
148
|
-
|
|
149
154
|
Task {
|
|
150
155
|
do {
|
|
151
156
|
let locs = await MPMapsIndoors.shared.locationsWith(query: try fromJSON(query), filter: try fromJSON(filter))
|
|
@@ -161,7 +166,7 @@ public class MapsIndoorsModule: NSObject {
|
|
|
161
166
|
|
|
162
167
|
@objc public func locationDisplayRuleExists(_ locId: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
|
|
163
168
|
if let location = MPMapsIndoors.shared.locationWith(locationId: locId) {
|
|
164
|
-
if
|
|
169
|
+
if MPMapsIndoors.shared.displayRuleFor(location: location) != nil {
|
|
165
170
|
return resolve(true)
|
|
166
171
|
} else {
|
|
167
172
|
return resolve(false)
|
|
@@ -172,13 +177,11 @@ public class MapsIndoorsModule: NSObject {
|
|
|
172
177
|
}
|
|
173
178
|
|
|
174
179
|
@objc public func displayRuleNameExists(_ name: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
|
|
175
|
-
|
|
176
180
|
let exists: Bool = MPMapsIndoors.shared.displayRuleFor(type: name.lowercased()) != nil
|
|
177
181
|
return resolve(exists)
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
@objc public func setPositionProvider(_ name: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
|
|
181
|
-
|
|
182
185
|
let provider = ReactPositionProvider()
|
|
183
186
|
provider.name = name
|
|
184
187
|
|
|
@@ -189,7 +192,6 @@ public class MapsIndoorsModule: NSObject {
|
|
|
189
192
|
}
|
|
190
193
|
|
|
191
194
|
@objc public func removePositionProvider(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
|
|
192
|
-
|
|
193
195
|
positionProvider = nil
|
|
194
196
|
MPMapsIndoors.shared.positionProvider = nil
|
|
195
197
|
|
|
@@ -214,7 +216,6 @@ public class MapsIndoorsModule: NSObject {
|
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
@objc public func applyUserRoles(_ userRolesJSON: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
|
|
217
|
-
|
|
218
219
|
do {
|
|
219
220
|
let userRoles: [MPUserRole] = try fromJSON(userRolesJSON)
|
|
220
221
|
MPMapsIndoors.shared.userRoles = userRoles
|
|
@@ -242,10 +243,9 @@ public class MapsIndoorsModule: NSObject {
|
|
|
242
243
|
}
|
|
243
244
|
|
|
244
245
|
@objc public func isReady(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
245
|
-
|
|
246
246
|
return resolve(MPMapsIndoors.shared.ready)
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
|
|
249
249
|
@objc public func getDefaultVenue(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
250
250
|
Task {
|
|
251
251
|
guard let defaultVenue = await MPMapsIndoors.shared.venues().first else {
|
|
@@ -254,17 +254,17 @@ public class MapsIndoorsModule: NSObject {
|
|
|
254
254
|
return resolve(toJSON(MPVenueCodable(withVenue: defaultVenue)))
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
@objc public func checkOfflineDataAvailability(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
259
259
|
Task {
|
|
260
260
|
guard let key = MPMapsIndoors.shared.apiKey else {
|
|
261
261
|
return reject("1", "isApiKeyValid: API key not set", nil)
|
|
262
262
|
}
|
|
263
|
-
|
|
263
|
+
|
|
264
264
|
return resolve(await MPMapsIndoors.shared.isOfflineDataAvailable(apiKey: key))
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
-
|
|
267
|
+
|
|
268
268
|
@objc public func destroy(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
269
269
|
Task {
|
|
270
270
|
MPMapsIndoors.shared.shutdown()
|
|
@@ -272,57 +272,53 @@ public class MapsIndoorsModule: NSObject {
|
|
|
272
272
|
return resolve(nil)
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
|
-
|
|
275
|
+
|
|
276
276
|
@objc public func isInitialized(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
277
277
|
return resolve(MapsIndoorsData.sharedInstance.isInitialized)
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
|
|
280
280
|
@objc public func setLanguage(_ language: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
|
|
281
|
-
|
|
282
281
|
MPMapsIndoors.shared.language = language
|
|
283
282
|
return resolve(nil)
|
|
284
283
|
}
|
|
285
|
-
|
|
284
|
+
|
|
286
285
|
@objc public func synchronizeContent(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
287
286
|
Task {
|
|
288
287
|
do {
|
|
289
288
|
try await MPMapsIndoors.shared.synchronize()
|
|
290
289
|
return resolve(nil)
|
|
291
|
-
}
|
|
292
|
-
catch let e {
|
|
290
|
+
} catch let e {
|
|
293
291
|
return doReject(reject, error: e)
|
|
294
292
|
}
|
|
295
293
|
}
|
|
296
294
|
}
|
|
297
295
|
|
|
298
296
|
@objc(addVenuesToSync:resolver:rejecter:)
|
|
299
|
-
func addVenuesToSync(venues: [String], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock)
|
|
297
|
+
func addVenuesToSync(venues: [String], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
300
298
|
Task {
|
|
301
299
|
do {
|
|
302
300
|
try await MPMapsIndoors.shared.addVenuesToSync(venueIds: venues)
|
|
303
301
|
return resolve(nil)
|
|
304
|
-
}
|
|
305
|
-
catch let e {
|
|
302
|
+
} catch let e {
|
|
306
303
|
return doReject(reject, error: e)
|
|
307
304
|
}
|
|
308
305
|
}
|
|
309
306
|
}
|
|
310
307
|
|
|
311
308
|
@objc(removeVenuesToSync:resolver:rejecter:)
|
|
312
|
-
func removeVenuesToSync(venues: [String], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock)
|
|
309
|
+
func removeVenuesToSync(venues: [String], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
313
310
|
Task {
|
|
314
311
|
do {
|
|
315
312
|
try await MPMapsIndoors.shared.removeVenuesToSync(venueIds: venues)
|
|
316
313
|
return resolve(nil)
|
|
317
|
-
}
|
|
318
|
-
catch let e {
|
|
314
|
+
} catch let e {
|
|
319
315
|
return doReject(reject, error: e)
|
|
320
316
|
}
|
|
321
317
|
}
|
|
322
318
|
}
|
|
323
319
|
|
|
324
320
|
@objc(getSyncedVenues:rejecter:)
|
|
325
|
-
func getSyncedVenues(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock)
|
|
321
|
+
func getSyncedVenues(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
326
322
|
return resolve(MPMapsIndoors.shared.venuesToSync)
|
|
327
323
|
}
|
|
328
324
|
|
|
@@ -335,28 +331,26 @@ public class MapsIndoorsModule: NSObject {
|
|
|
335
331
|
if dataSet == nil {
|
|
336
332
|
return resolve(false)
|
|
337
333
|
}
|
|
338
|
-
|
|
339
|
-
|
|
334
|
+
|
|
340
335
|
datasetCacheManager.delegate = DatasetDelegate(promise: resolve, dataset: dataSet!.cacheItem)
|
|
341
|
-
|
|
336
|
+
|
|
342
337
|
datasetCacheManager.synchronizeCacheItems([dataSet!.cacheItem])
|
|
343
338
|
}
|
|
344
|
-
|
|
345
339
|
}
|
|
346
340
|
|
|
347
341
|
class DatasetDelegate: NSObject, MPDataSetCacheManagerDelegate {
|
|
348
342
|
var promise: RCTPromiseResolveBlock
|
|
349
343
|
var dataset: MPDataSetCacheItem
|
|
350
|
-
|
|
344
|
+
|
|
351
345
|
init(promise: @escaping RCTPromiseResolveBlock, dataset: MPDataSetCacheItem) {
|
|
352
346
|
self.promise = promise
|
|
353
347
|
self.dataset = dataset
|
|
354
348
|
}
|
|
355
|
-
|
|
349
|
+
|
|
356
350
|
func dataSetManager(_ dataSetManager: MPDataSetCacheManager, didFinishSynchronizingItem item: MPDataSetCacheItem) {
|
|
357
351
|
if item.cachingItemId == dataset.cachingItemId {
|
|
358
352
|
return promise(true)
|
|
359
|
-
}else {
|
|
353
|
+
} else {
|
|
360
354
|
return promise(false)
|
|
361
355
|
}
|
|
362
356
|
}
|
package/ios/core/RCMapView.swift
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
-
|
|
3
2
|
import MapsIndoors
|
|
4
3
|
|
|
5
4
|
public class ReactPositionProvider: MPPositionProvider {
|
|
@@ -15,7 +14,7 @@ public class ReactPositionProvider: MPPositionProvider {
|
|
|
15
14
|
|
|
16
15
|
public func setLatestPosition(positionResult: MPPositionResult) {
|
|
17
16
|
DispatchQueue.main.async {
|
|
18
|
-
if
|
|
17
|
+
if self.latestPosition?.floorIndex != positionResult.floorIndex {
|
|
19
18
|
let floorSelector = self.mapsIndoorsData.floorSelector
|
|
20
19
|
floorSelector?.onUserPositionFloorChange(floorIndex: positionResult.floorIndex)
|
|
21
20
|
}
|
package/ios/core/RouteIcon.swift
CHANGED
|
@@ -5,29 +5,29 @@
|
|
|
5
5
|
// Created by Tim Mikkelsen on 15/05/2024.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import MapsIndoorsCore
|
|
9
8
|
import Foundation
|
|
9
|
+
import MapsIndoorsCore
|
|
10
10
|
|
|
11
11
|
struct RouteIcon: Codable {
|
|
12
12
|
let numbered: Bool
|
|
13
13
|
let label: String
|
|
14
14
|
let color: String
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
public func getIcon() -> MPRouteStopIconConfig {
|
|
17
17
|
return MPRouteStopIconConfig(numbered: numbered, label: label, color: try! colorFromHexString(hex: color))
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
private func colorFromHexString(hex: String) throws -> UIColor {
|
|
21
21
|
let regex = try! NSRegularExpression(pattern: "^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{8}$")
|
|
22
22
|
let range = NSRange(location: 0, length: hex.utf16.count)
|
|
23
23
|
|
|
24
|
-
if
|
|
24
|
+
if regex.matches(in: hex, range: range).count == 1 {
|
|
25
25
|
return UIColor(hex: hex)!
|
|
26
26
|
} else {
|
|
27
|
-
|
|
27
|
+
throw HexParsingError.invalidHexString(hex)
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
enum HexParsingError: Error {
|
|
32
32
|
case invalidHexString(String)
|
|
33
33
|
}
|