@mapsindoors/react-native-maps-indoors-mapbox 1.0.0 → 1.0.1

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.
Files changed (38) hide show
  1. package/README.md +2 -6
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  7. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  8. package/android/.idea/jarRepositories.xml +15 -0
  9. package/android/.idea/misc.xml +1 -1
  10. package/android/.idea/vcs.xml +2 -1
  11. package/android/build.gradle +2 -5
  12. package/android/src/main/java/com/reactlibrary/MapboxMapView.java +6 -2
  13. package/android/src/main/java/com/reactlibrary/MapsIndoorsPackage.java +3 -1
  14. package/android/src/main/java/com/reactlibrary/core/MPDisplayRuleModule.java +1 -1
  15. package/android/src/main/java/com/reactlibrary/core/MapControlModule.java +16 -8
  16. package/android/src/main/java/com/reactlibrary/core/README.md +90 -1
  17. package/android/src/main/java/com/reactlibrary/core/UtilsModule.java +11 -10
  18. package/ios/MapsIndoorsViewManager.swift +3 -1
  19. package/ios/core/DirectionsRendererBridge.m +8 -4
  20. package/ios/core/DirectionsRendererModule.swift +73 -33
  21. package/ios/core/MapControlModule.swift +14 -11
  22. package/ios/core/MapsIndoorsData.swift +17 -2
  23. package/ios/core/README.md +89 -1
  24. package/package.json +1 -1
  25. package/react-native-maps-indoors-mapbox.podspec +2 -2
  26. package/src/core/MPBounds.ts +13 -3
  27. package/src/core/MPBuilding.ts +3 -3
  28. package/src/core/MPCameraPosition.ts +2 -2
  29. package/src/core/MPFilterBehavior.ts +5 -5
  30. package/src/core/MPLocation.ts +2 -2
  31. package/src/core/MPMultiPolygon.ts +17 -4
  32. package/src/core/MPPoint.ts +9 -4
  33. package/src/core/MPPolygon.ts +17 -4
  34. package/src/core/MPPropertyData.ts +1 -1
  35. package/src/core/MPSelectionBehavior.ts +5 -5
  36. package/src/core/MPSolutionConfig.ts +2 -2
  37. package/src/core/MapControl.ts +4 -1
  38. package/src/core/README.md +89 -1
@@ -13,7 +13,7 @@ import React
13
13
  public class DirectionsRendererModule: RCTEventEmitter {
14
14
  private var directionsRenderer: MPDirectionsRenderer? = nil
15
15
  private var isListeningForLegChanges: Bool = false
16
-
16
+
17
17
  @objc public override static func requiresMainQueueSetup() -> Bool { return false }
18
18
 
19
19
  /// Base overide for RCTEventEmitter.
@@ -22,50 +22,54 @@ public class DirectionsRendererModule: RCTEventEmitter {
22
22
  @objc open override func supportedEvents() -> [String] {
23
23
  return MapsIndoorsData.sharedInstance.allEvents
24
24
  }
25
-
25
+
26
26
  @objc public func clear(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
27
27
  if (directionsRenderer == nil) {
28
28
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
29
29
  }
30
-
30
+
31
31
  guard let directionsRenderer else {
32
32
  return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
33
33
  }
34
+
34
35
  DispatchQueue.main.sync {
35
36
  directionsRenderer.clear()
36
37
  }
37
38
  return resolve(nil)
38
39
  }
39
-
40
+
40
41
  @objc public func getSelectedLegFloorIndex(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
41
42
  if (directionsRenderer == nil) {
42
43
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
43
44
  }
44
-
45
+
45
46
  guard let directionsRenderer else {
46
47
  return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
47
48
  }
48
49
 
50
+ directionsRenderer.padding = MapsIndoorsData.sharedInstance.mapControl!.mapPadding
51
+
49
52
  guard let legIndex = directionsRenderer.route?.legs[directionsRenderer.routeLegIndex].end_location.zLevel.int32Value else {
50
53
  return doReject(reject, message: "No current floor available")
51
54
  }
52
-
55
+
53
56
  return resolve(legIndex)
54
57
  }
55
-
58
+
56
59
  @objc public func nextLeg(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
57
60
  if (directionsRenderer == nil) {
58
61
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
59
62
  }
60
-
63
+
61
64
  guard let directionsRenderer else {
62
65
  return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
63
66
  }
64
67
 
68
+ directionsRenderer.padding = MapsIndoorsData.sharedInstance.mapControl!.mapPadding
65
69
 
66
70
  DispatchQueue.main.sync {
67
71
  let succes = directionsRenderer.nextLeg()
68
-
72
+
69
73
  if succes {
70
74
  directionsRenderer.animate(duration: 5)
71
75
  if (isListeningForLegChanges) {
@@ -75,19 +79,21 @@ public class DirectionsRendererModule: RCTEventEmitter {
75
79
  }
76
80
  return resolve(nil)
77
81
  }
78
-
82
+
79
83
  @objc public func previousLeg(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
80
84
  if (directionsRenderer == nil) {
81
85
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
82
86
  }
83
-
87
+
84
88
  guard let directionsRenderer else {
85
89
  return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
86
90
  }
87
-
88
- let succes = directionsRenderer.previousLeg()
91
+
92
+ directionsRenderer.padding = MapsIndoorsData.sharedInstance.mapControl!.mapPadding
89
93
 
90
94
  DispatchQueue.main.sync {
95
+ let succes = directionsRenderer.previousLeg()
96
+
91
97
  if succes {
92
98
  directionsRenderer.animate(duration: 5)
93
99
  if (isListeningForLegChanges) {
@@ -95,92 +101,126 @@ public class DirectionsRendererModule: RCTEventEmitter {
95
101
  }
96
102
  }
97
103
  }
98
-
104
+
99
105
  return resolve(nil)
100
106
  }
101
-
107
+
102
108
  @objc public func selectLegIndex(_ legIndex: NSNumber, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
103
109
  if (directionsRenderer == nil) {
104
110
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
105
111
  }
106
-
112
+
107
113
  guard let directionsRenderer else {
108
114
  return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
109
115
  }
110
-
116
+
111
117
  guard let route = directionsRenderer.route else {
112
118
  return doReject(reject, message: "No route is set")
113
119
  }
114
-
115
- if (route.legs.count) < legIndex.intValue || legIndex.intValue < 0 {
116
- return resolve(nil)
120
+
121
+ guard legIndex.intValue >= 0 else {
122
+ return doReject(reject, message: "Tried to select negative route leg index \(legIndex.intValue)")
117
123
  }
124
+
125
+ guard legIndex.intValue < (route.legs.count) else {
126
+ return doReject(reject, message: "Tried to select route leg index \(legIndex.intValue) outside of range 0..\((route.legs.count)-1)")
127
+ }
128
+
129
+ directionsRenderer.padding = MapsIndoorsData.sharedInstance.mapControl!.mapPadding
118
130
 
119
131
  DispatchQueue.main.sync {
120
132
  directionsRenderer.routeLegIndex = legIndex.intValue
121
-
133
+
122
134
  directionsRenderer.animate(duration: 5)
123
-
135
+
124
136
  if isListeningForLegChanges {
125
137
  sendEvent(withName: MapsIndoorsData.Event.onLegSelected.rawValue, body: ["leg": directionsRenderer.routeLegIndex])
126
138
  }
127
139
  }
128
140
  return resolve(nil)
129
141
  }
130
-
142
+
131
143
  @objc public func setAnimatedPolyline(_ animated: Bool, repeated: Bool, duration: NSNumber, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
132
144
  if (directionsRenderer == nil) {
133
145
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
134
146
  }
147
+
148
+ guard let directionsRenderer else {
149
+ return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
150
+ }
151
+
152
+ if (animated) {
153
+ DispatchQueue.main.sync {
154
+ directionsRenderer.animate(duration: duration.doubleValue)
155
+ }
156
+ }
157
+
158
+ return resolve(nil)
159
+ }
160
+
161
+ @objc public func setCameraAnimationDuration(_ duration: NSNumber, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
162
+ if (directionsRenderer != nil) {
163
+ directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
164
+ }
135
165
 
136
166
  guard let directionsRenderer else {
137
167
  return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
138
168
  }
139
169
 
140
- if (animated) {
170
+ DispatchQueue.main.async {
141
171
  directionsRenderer.animate(duration: duration.doubleValue)
142
172
  }
143
173
 
144
174
  return resolve(nil)
145
175
  }
146
-
176
+
147
177
  @objc public func setCameraViewFitMode(_ cameraFitMode: NSNumber, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
148
178
  if (directionsRenderer == nil) {
149
179
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
150
180
  }
151
-
181
+
152
182
  guard let directionsRenderer else {
153
183
  return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
154
184
  }
155
185
 
156
- guard let cameraViewFitMode = MPCameraViewFitMode(rawValue: cameraFitMode.intValue) else {
157
- return doReject(reject, message: "CameraFitMode not found")
186
+ var camFitMode: MPCameraViewFitMode? = nil
187
+
188
+ switch cameraFitMode {
189
+ case 0:
190
+ camFitMode = MPCameraViewFitMode.northAligned
191
+ case 1:
192
+ camFitMode = MPCameraViewFitMode.firstStepAligned
193
+ case 2:
194
+ camFitMode = MPCameraViewFitMode.startToEndAligned
195
+ default:
196
+ camFitMode = MPCameraViewFitMode.northAligned
158
197
  }
159
198
 
160
- directionsRenderer.fitMode = cameraViewFitMode
199
+ directionsRenderer.fitMode = camFitMode!
161
200
  return resolve(nil)
162
201
  }
163
-
202
+
164
203
  @objc public func setOnLegSelectedListener(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
165
204
  isListeningForLegChanges = true
166
205
  return resolve(nil)
167
206
  }
168
-
207
+
169
208
  @objc public func setPolyLineColors(_ foregroundString: String, backgroundString: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
170
209
  if (directionsRenderer == nil) {
171
210
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
172
211
  }
173
212
  }
174
-
213
+
175
214
  @objc public func setRoute(_ routeString: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
176
215
  if (directionsRenderer == nil) {
177
216
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
178
217
  }
179
-
218
+
180
219
  guard let directionsRenderer else {
181
220
  return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
182
221
  }
183
222
 
223
+ directionsRenderer.padding = MapsIndoorsData.sharedInstance.mapControl!.mapPadding
184
224
 
185
225
  guard let route = try? JSONDecoder().decode(MPRouteCodable.self, from: Data(routeString.utf8)) else {
186
226
  return doReject(reject, message: "Route could not be parsed")
@@ -221,14 +221,15 @@ public class MapControlModule: RCTEventEmitter {
221
221
  }
222
222
 
223
223
  @objc public func setMapPadding(_ left: Int, top: Int, right: Int, bottom: Int,
224
- resolver resolve: RCTPromiseResolveBlock,
225
- rejecter reject: RCTPromiseRejectBlock) {
224
+ resolver resolve: @escaping RCTPromiseResolveBlock,
225
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
226
226
 
227
227
  let edgeInsets = UIEdgeInsets(top: CGFloat(top), left: CGFloat(left), bottom: CGFloat(bottom), right: CGFloat(right))
228
228
 
229
- MapsIndoorsData.sharedInstance.mapControl?.mapPadding = edgeInsets
230
-
231
- return resolve(nil)
229
+ DispatchQueue.main.async {
230
+ MapsIndoorsData.sharedInstance.mapControl?.mapPadding = edgeInsets
231
+ return resolve(nil)
232
+ }
232
233
  }
233
234
 
234
235
  @objc public func getMapViewPaddingStart(_ resolve: RCTPromiseResolveBlock,
@@ -338,18 +339,20 @@ public class MapControlModule: RCTEventEmitter {
338
339
  }
339
340
 
340
341
  @objc public func animateCamera(_ updateJSON: String,
341
- duration: Int, //TODO: confirm if Int is fine here (any useful distinction between 0 and nil here?) //_duration: NSNumber, // TODO: check if NSNumber matches java @Nullable
342
+ duration: Int,
342
343
  resolver resolve: RCTPromiseResolveBlock,
343
344
  rejecter reject: RCTPromiseRejectBlock) {
344
345
  guard let mapView = MapsIndoorsData.sharedInstance.mapView else {
345
346
  return doReject(reject, message: "Google maps not available")
346
347
  }
347
348
 
348
- // /*if*/ let duration = _duration.intValue // Only used if using _duration: NSNumber to match @Nullable in Java
349
349
  do {
350
350
  let cameraUpdate: CameraUpdate = try fromJSON(updateJSON)
351
-
352
- try mapView.animateCamera(cameraUpdate: cameraUpdate, duration: duration)
351
+ if (duration == -1) {
352
+ try mapView.moveCamera(cameraUpdate: cameraUpdate)
353
+ }else {
354
+ try mapView.animateCamera(cameraUpdate: cameraUpdate, duration: duration)
355
+ }
353
356
 
354
357
  return resolve(nil)
355
358
  } catch let e /*as CameraUpdateError*/ {
@@ -460,8 +463,8 @@ public class MapControlModule: RCTEventEmitter {
460
463
  }
461
464
 
462
465
  @objc public func setMPCameraEventListener(_ setup: Bool, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
463
-
464
- return doReject(reject, message: "NOT IMPLEMENTED")
466
+ MapsIndoorsData.sharedInstance.mapControlListenerDelegate?.respondToCameraEvents = setup
467
+ return resolve(nil)
465
468
  }
466
469
 
467
470
  // Floor selector
@@ -56,12 +56,13 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
56
56
  var consumeChangeLocation: Bool = false
57
57
 
58
58
  var respondToDidTapInfoWindow: Bool = false
59
-
60
- // TODO: camera event not implemented on iOS v4
59
+
60
+ var respondToCameraEvents: Bool = false
61
61
 
62
62
  init(eventEmitter: RCTEventEmitter) {
63
63
  self.eventEmitter = eventEmitter
64
64
  }
65
+
65
66
 
66
67
  private func sendEvent(event: MapsIndoorsData.Event, body: [String: Any?]) {
67
68
  eventEmitter.sendEvent(withName: event.rawValue, body: body)
@@ -69,6 +70,20 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
69
70
 
70
71
  // MPMapControlDelegate:
71
72
 
73
+ func cameraIdle() -> Bool {
74
+ if (respondToCameraEvents) {
75
+ sendEvent(event: .cameraEvent, body: ["event": 7])
76
+ }
77
+ return true;
78
+ }
79
+
80
+ func cameraWillMove() -> Bool {
81
+ if (respondToCameraEvents) {
82
+ sendEvent(event: .cameraEvent, body: ["event": 5])
83
+ }
84
+ return true;
85
+ }
86
+
72
87
  func didTap(coordinate: MPPoint) -> Bool {
73
88
  if (respondToTap) {
74
89
  sendEvent(event: .onMapClick, body: ["point": toJSON(coordinate)])
@@ -1,4 +1,92 @@
1
1
  # react-native-mapsindoors-core-ios
2
2
 
3
3
 
4
- iOS core logic for react native mapsindoors sdk
4
+
5
+ ## Getting started
6
+
7
+ To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8
+
9
+ Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10
+
11
+ ## Add your files
12
+
13
+ - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14
+ - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15
+
16
+ ```
17
+ cd existing_repo
18
+ git remote add origin https://git.rtx.mapspeople.com/timi/react-native-mapsindoors-core-ios.git
19
+ git branch -M main
20
+ git push -uf origin main
21
+ ```
22
+
23
+ ## Integrate with your tools
24
+
25
+ - [ ] [Set up project integrations](https://git.rtx.mapspeople.com/timi/react-native-mapsindoors-core-ios/-/settings/integrations)
26
+
27
+ ## Collaborate with your team
28
+
29
+ - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30
+ - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31
+ - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32
+ - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33
+ - [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34
+
35
+ ## Test and Deploy
36
+
37
+ Use the built-in continuous integration in GitLab.
38
+
39
+ - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40
+ - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41
+ - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42
+ - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43
+ - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44
+
45
+ ***
46
+
47
+ # Editing this README
48
+
49
+ When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
50
+
51
+ ## Suggestions for a good README
52
+ Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
53
+
54
+ ## Name
55
+ Choose a self-explaining name for your project.
56
+
57
+ ## Description
58
+ Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
59
+
60
+ ## Badges
61
+ On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
62
+
63
+ ## Visuals
64
+ Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
65
+
66
+ ## Installation
67
+ Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
68
+
69
+ ## Usage
70
+ Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
71
+
72
+ ## Support
73
+ Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
74
+
75
+ ## Roadmap
76
+ If you have ideas for releases in the future, it is a good idea to list them in the README.
77
+
78
+ ## Contributing
79
+ State if you are open to contributions and what your requirements are for accepting them.
80
+
81
+ For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
82
+
83
+ You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
84
+
85
+ ## Authors and acknowledgment
86
+ Show your appreciation to those who have contributed to the project.
87
+
88
+ ## License
89
+ For open source projects, say how it is licensed.
90
+
91
+ ## Project status
92
+ If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mapsindoors/react-native-maps-indoors-mapbox",
3
3
  "title": "React Native MapsIndoors Mapbox",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "description": "React Native MapsIndoors component with mapbox",
6
6
  "react-native": "index.ts",
7
7
  "files": [
@@ -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 "MapsIndoorsMapbox", "4.2.1"
28
- s.dependency "MapsIndoorsCodable", "4.2.1"
27
+ s.dependency "MapsIndoorsMapbox", "4.2.2"
28
+ s.dependency "MapsIndoorsCodable", "4.2.2"
29
29
  end
30
30
 
@@ -1,4 +1,5 @@
1
1
  import MPPoint from "./MPPoint";
2
+ import { Platform } from "react-native";
2
3
 
3
4
  /**
4
5
  * A simple representation of a bounding box.
@@ -87,10 +88,19 @@ export default class MPBounds {
87
88
  ((point.longitude <= this.northeast.longitude &&
88
89
  point.longitude >= this.southwest.longitude));
89
90
  }
91
+
92
+
90
93
  public toJSON() {
91
- return {
92
- "northeast": [this.northeast.longitude, this.northeast.latitude],
93
- "southwest": [this.southwest.longitude, this.southwest.latitude]
94
+ if(Platform.OS === 'ios') {
95
+ return {
96
+ "northeast": [this.northeast.longitude, this.northeast.latitude],
97
+ "southwest": [this.southwest.longitude, this.southwest.latitude],
98
+ }
99
+ } else {
100
+ return {
101
+ "northeast": this.northeast,
102
+ "southwest": this.southwest,
103
+ }
94
104
  }
95
105
  }
96
106
 
@@ -138,7 +138,7 @@ export default class MPBuilding extends MPEntity {
138
138
  * @type {string}
139
139
  */
140
140
  public get name(): string {
141
- return this.buildingInfo?.name ?? "";
141
+ return this.buildingInfo?.name ? this.buildingInfo.name : "";
142
142
  }
143
143
 
144
144
  /**
@@ -149,7 +149,7 @@ export default class MPBuilding extends MPEntity {
149
149
  * @type {string[]}
150
150
  */
151
151
  public get aliases(): string[] {
152
- return this.buildingInfo?.aliases ?? [];
152
+ return this.buildingInfo?.aliases ? this.buildingInfo.aliases : [];
153
153
  }
154
154
 
155
155
  /**
@@ -182,7 +182,7 @@ export default class MPBuilding extends MPEntity {
182
182
  * @type {number}
183
183
  */
184
184
  public get initialFloorIndex(): number {
185
- return this.defaultFloor ?? this.floors[0].floorIndex ?? 0;
185
+ return this.defaultFloor ? this.defaultFloor : this.floors[0].floorIndex ? this.floors[0].floorIndex : 0;
186
186
  }
187
187
 
188
188
  /**
@@ -41,8 +41,8 @@ export default class MPCameraPosition {
41
41
  return new MPCameraPosition(
42
42
  object?.zoom,
43
43
  target,
44
- object?.bearing ?? 0,
45
- object?.tilt ?? 0,
44
+ object?.bearing ? object.bearing : 0,
45
+ object?.tilt ? object.tilt : 0,
46
46
  );
47
47
  }
48
48
  }
@@ -45,11 +45,11 @@ export default class MPFilterBehavior {
45
45
  */
46
46
  public static create(object?: MPFilterBehaviorParams): MPFilterBehavior {
47
47
  return new MPFilterBehavior(
48
- object?.allowFloorChange ?? false,
49
- object?.moveCamera ?? false,
50
- object?.animationDuration ?? 0,
51
- object?.showInfoWindow ?? false,
52
- object?.zoomToFit ?? true
48
+ object?.allowFloorChange ? object.allowFloorChange : false,
49
+ object?.moveCamera ? object.moveCamera : false,
50
+ object?.animationDuration ? object.animationDuration : 0,
51
+ object?.showInfoWindow ? object.showInfoWindow : false,
52
+ object?.zoomToFit ? object?.zoomToFit : true
53
53
  );
54
54
  };
55
55
  }
@@ -41,7 +41,7 @@ export default class MPLocation extends MPEntity {
41
41
  * @type {MPPoint}
42
42
  */
43
43
  public override get position(): MPPoint {
44
- return this.properties?.anchor ?? new MPPoint(0, 0);
44
+ return this.properties?.anchor ? this.properties.anchor : new MPPoint(0, 0);
45
45
  }
46
46
 
47
47
  /**
@@ -280,7 +280,7 @@ export default class MPLocation extends MPEntity {
280
280
  * @returns {boolean}
281
281
  */
282
282
  public isBookable(): boolean {
283
- return this.properties?.bookable ?? false;
283
+ return this.properties?.bookable ? this.properties.bookable : false;
284
284
  }
285
285
 
286
286
  /**
@@ -95,7 +95,10 @@ export default class MPMultiPolygon extends MPGeometry {
95
95
  * @type {MPBounds}
96
96
  */
97
97
  public get bounds(): MPBounds {
98
- return this._bounds ??= MPBounds.fromBBox(this._bbox);
98
+ if (this._bounds == undefined) {
99
+ this._bounds = MPBounds.fromBBox(this._bbox);
100
+ }
101
+ return this._bounds;
99
102
  }
100
103
 
101
104
  /**
@@ -106,7 +109,10 @@ export default class MPMultiPolygon extends MPGeometry {
106
109
  * @returns {Promise<number>}
107
110
  */
108
111
  public async getArea(): Promise<number> {
109
- return Promise.resolve(this._area ??= await MPUtils.geometryArea(this));
112
+ if (this._area == undefined) {
113
+ this._area = await MPUtils.geometryArea(this);
114
+ }
115
+ return Promise.resolve(this._area);
110
116
  }
111
117
 
112
118
 
@@ -174,8 +180,9 @@ export default class MPMultiPolygon extends MPGeometry {
174
180
  */
175
181
  public toJSON(): MPMultiPolygonParams {
176
182
  return {
177
- "coordinates": this._coordinates,
178
- "bbox": this._bbox,
183
+ type: this.type,
184
+ coordinates: this._coordinates,
185
+ bbox: this._bbox,
179
186
  }
180
187
  }
181
188
  }
@@ -190,6 +197,12 @@ export default class MPMultiPolygon extends MPGeometry {
190
197
  */
191
198
  export interface MPMultiPolygonParams {
192
199
 
200
+ /**
201
+ * the type of the geometry, leave this blank as it is just used to parse the geometry to JSON
202
+ *
203
+ * @type {string}
204
+ */
205
+ type?: string,
193
206
  /**
194
207
  * Geometry, as specified in the [GeoJSON format]{@link https://stevage.github.io/geojson-spec/#section-3.1.7}.
195
208
  *
@@ -63,14 +63,12 @@ export default class MPPoint extends MPGeometry {
63
63
  * @param {MPPointParams} pointParams
64
64
  * @returns {MPPoint}
65
65
  */
66
- public static create(pointParams: MPPointParams): MPPoint | undefined {
66
+ public static create(pointParams: MPPointParams): MPPoint {
67
67
  if (pointParams?.coordinates) {
68
68
  return new MPPoint(pointParams.coordinates[1], pointParams.coordinates[0], pointParams.coordinates[2]);
69
69
  } else if (pointParams as unknown as number[]){
70
70
  const pp = pointParams as unknown as number[]
71
71
  return new MPPoint(pp[1], pp[0], pp[2]);
72
- }else {
73
- return null;
74
72
  }
75
73
  }
76
74
 
@@ -140,7 +138,8 @@ export default class MPPoint extends MPGeometry {
140
138
  */
141
139
  public toJSON(): MPPointParams {
142
140
  return {
143
- coordinates: [this.longitude, this.latitude, this.floorIndex ?? 0],
141
+ type: this.type,
142
+ coordinates: [this.longitude, this.latitude, this.floorIndex ? this.floorIndex : 0],
144
143
  };
145
144
  }
146
145
  }
@@ -153,6 +152,12 @@ export default class MPPoint extends MPGeometry {
153
152
  * @typedef {MPPointParams}
154
153
  */
155
154
  export interface MPPointParams {
155
+ /**
156
+ * the type of the geometry, leave this blank as it is just used to parse the geometry to JSON
157
+ *
158
+ * @type {string}
159
+ */
160
+ type?: string,
156
161
  /**
157
162
  * Coordinate holder for point, on the form:.
158
163
  *