@mapsindoors/react-native-maps-indoors-mapbox 2.0.5 → 2.0.6
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
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Documentation
|
|
4
4
|
|
|
5
|
-
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.0.
|
|
5
|
+
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.0.6/index.html) to get an overview of what the MapsIndoors SDK offers.
|
|
6
6
|
|
|
7
7
|
## Getting started
|
|
8
8
|
|
|
@@ -20,7 +20,6 @@ private func doReject(_ reject: RCTPromiseRejectBlock, displayRuleId: String,
|
|
|
20
20
|
|
|
21
21
|
@objc(DisplayRule)
|
|
22
22
|
public class MPDisplayRuleModule: NSObject {
|
|
23
|
-
private var refreshTimerWorkItem: DispatchWorkItem?
|
|
24
23
|
|
|
25
24
|
@objc static func requiresMainQueueSetup() -> Bool { return false }
|
|
26
25
|
|
|
@@ -89,31 +88,16 @@ public class MPDisplayRuleModule: NSObject {
|
|
|
89
88
|
|
|
90
89
|
private func getRule(name: String) -> MPDisplayRule? {
|
|
91
90
|
if let typeRule = getTypeRule(typeName: name) {
|
|
92
|
-
setRefreshTimer()
|
|
93
91
|
return MPMapsIndoors.shared.displayRuleFor(displayRuleType: typeRule)
|
|
94
92
|
} else if let namedRule = MPMapsIndoors.shared.displayRuleFor(type: name.lowercased()){
|
|
95
|
-
setRefreshTimer()
|
|
96
93
|
return namedRule
|
|
97
94
|
} else if let loc = MPMapsIndoors.shared.locationWith(locationId: name) {
|
|
98
|
-
setRefreshTimer()
|
|
99
95
|
return MPMapsIndoors.shared.displayRuleFor(location: loc)!
|
|
100
96
|
} else {
|
|
101
97
|
return nil
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
|
|
105
|
-
func setRefreshTimer() {
|
|
106
|
-
refreshTimerWorkItem?.cancel()
|
|
107
|
-
|
|
108
|
-
refreshTimerWorkItem = DispatchWorkItem {
|
|
109
|
-
MapsIndoorsData.sharedInstance.mapView?.getMapControl()?.refresh()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if let refreshTimerWorkItem {
|
|
113
|
-
DispatchQueue.global().asyncAfter(deadline: .now() + 0.5, execute: refreshTimerWorkItem)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
101
|
func hexStringFromColor(color: UIColor) -> String {
|
|
118
102
|
// TODO: copy paste from Flutter
|
|
119
103
|
let components = color.cgColor.components
|
|
@@ -551,7 +551,8 @@ public class MapControlModule: RCTEventEmitter {
|
|
|
551
551
|
}
|
|
552
552
|
|
|
553
553
|
do {
|
|
554
|
-
|
|
554
|
+
let floor: MPFloorCodable = try fromJSON(newFloorJson)
|
|
555
|
+
floorSelector.onFloorSelectionChanged(newFloor: floor.floorIndex ?? 0)
|
|
555
556
|
return resolve(nil)
|
|
556
557
|
} catch let e {
|
|
557
558
|
return doReject(reject, error: e)
|
|
@@ -111,6 +111,8 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
111
111
|
if (respondToDidChangeFloorIndex) {
|
|
112
112
|
sendEvent(event: .onFloorUpdate, body: ["floorIndex": floorIndex])
|
|
113
113
|
}
|
|
114
|
+
|
|
115
|
+
MapsIndoorsData.sharedInstance.floorSelector?.onFloorSelectionChanged(newFloor: NSNumber(value: floorIndex))
|
|
114
116
|
return false
|
|
115
117
|
}
|
|
116
118
|
|
|
@@ -125,6 +127,7 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
125
127
|
if (respondToDidChangeBuilding) {
|
|
126
128
|
sendEvent(event: .onBuildingFoundAtCameraTarget, body: ["building": selectedBuilding.map{ toJSON(MPBuildingCodable(withBuilding:($0))) }])
|
|
127
129
|
}
|
|
130
|
+
MapsIndoorsData.sharedInstance.floorSelector?.building = selectedBuilding
|
|
128
131
|
return false
|
|
129
132
|
}
|
|
130
133
|
|
|
@@ -157,10 +160,11 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
|
|
|
157
160
|
|
|
158
161
|
func onFloorIndexChanged(_ floorIndex: NSNumber) {
|
|
159
162
|
sendEvent(event: .onFloorUpdate, body: ["floorIndex": floorIndex])
|
|
163
|
+
MapsIndoorsData.sharedInstance.floorSelector?.onFloorSelectionChanged(newFloor: floorIndex)
|
|
160
164
|
}
|
|
161
165
|
|
|
162
166
|
func floorSelector(method: FloorSelector.Event, args: [String: Any]) {
|
|
163
|
-
let body = try! ["method": method].merging(args, uniquingKeysWith: { _,_ in throw MPError.unknownError })
|
|
167
|
+
let body = try! ["method": method.rawValue].merging(args, uniquingKeysWith: { _,_ in throw MPError.unknownError })
|
|
164
168
|
|
|
165
169
|
sendEvent(event: .floorSelector, body: body)
|
|
166
170
|
}
|
|
@@ -175,13 +179,21 @@ class FloorSelector: UIView, MPCustomFloorSelector {
|
|
|
175
179
|
case setUserPositionFloor
|
|
176
180
|
// TODO: the rest are not implemented since they are not available from the MPCustomFloorSelector protocol, and are not implemented in flutter
|
|
177
181
|
// case setSelectedFloor
|
|
178
|
-
|
|
182
|
+
case setSelectedFloorByFloorIndex
|
|
179
183
|
// case zoomLevelChanged
|
|
180
184
|
}
|
|
185
|
+
|
|
186
|
+
lazy var allEvents: [String] = {
|
|
187
|
+
var allEventNames: [String] = Event.allCases.map{$0.rawValue}
|
|
188
|
+
return allEventNames
|
|
189
|
+
}()
|
|
181
190
|
|
|
182
191
|
var building: MapsIndoors.MPBuilding?
|
|
192
|
+
var latestBuilding: MapsIndoors.MPBuilding?
|
|
183
193
|
var delegate: MapsIndoors.MPFloorSelectorDelegate?
|
|
184
194
|
|
|
195
|
+
var hide: Bool = false
|
|
196
|
+
|
|
185
197
|
var floorIndex: NSNumber?
|
|
186
198
|
|
|
187
199
|
var autoFloorChange = true
|
|
@@ -200,22 +212,35 @@ class FloorSelector: UIView, MPCustomFloorSelector {
|
|
|
200
212
|
super.init(frame: CGRect())
|
|
201
213
|
}
|
|
202
214
|
|
|
203
|
-
func onFloorSelectionChanged(newFloor:
|
|
204
|
-
let floorIndex = newFloor.
|
|
205
|
-
|
|
215
|
+
func onFloorSelectionChanged(newFloor: NSNumber) {
|
|
216
|
+
let floorIndex = newFloor.intValue
|
|
217
|
+
listenerDelegate.floorSelector(method: .setSelectedFloorByFloorIndex, args: ["floorIndex": newFloor])
|
|
206
218
|
}
|
|
207
219
|
|
|
208
220
|
func onShow() {
|
|
221
|
+
if (!hide && building === latestBuilding) {
|
|
222
|
+
return
|
|
223
|
+
}
|
|
209
224
|
if let building {
|
|
210
225
|
listenerDelegate.floorSelector(method: .setList, args: [
|
|
211
|
-
"list": toJSON(building.floors?.values.
|
|
226
|
+
"list": toJSON(building.floors?.values.sorted(by: { (floor1, floor2) -> Bool in
|
|
227
|
+
return floor1.floorIndex!.intValue < floor2.floorIndex!.intValue
|
|
228
|
+
}).map{MPFloorCodable(withFloor: $0)})
|
|
212
229
|
])
|
|
213
230
|
}
|
|
214
231
|
|
|
215
232
|
listenerDelegate.floorSelector(method: .show, args: ["show": true, "animated": true])
|
|
233
|
+
latestBuilding = building
|
|
234
|
+
hide = false
|
|
216
235
|
}
|
|
236
|
+
|
|
217
237
|
func onHide() {
|
|
238
|
+
if (hide) {
|
|
239
|
+
return
|
|
240
|
+
}
|
|
218
241
|
listenerDelegate.floorSelector(method: .show, args: ["show": false, "animated": true])
|
|
242
|
+
latestBuilding = nil
|
|
243
|
+
hide = true
|
|
219
244
|
}
|
|
220
245
|
|
|
221
246
|
func onUserPositionFloorChange(floorIndex: Int) {
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ Pod::Spec.new do |s|
|
|
|
24
24
|
s.requires_arc = true
|
|
25
25
|
|
|
26
26
|
s.dependency "React"
|
|
27
|
-
s.dependency "MapsIndoorsMapbox11", "4.5.
|
|
28
|
-
s.dependency "MapsIndoorsCodable", "4.5.
|
|
27
|
+
s.dependency "MapsIndoorsMapbox11", "4.5.13"
|
|
28
|
+
s.dependency "MapsIndoorsCodable", "4.5.13"
|
|
29
29
|
end
|
|
30
30
|
|