@mapsindoors/react-native-maps-indoors-mapbox 2.6.1 → 2.6.2-rc.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 (132) hide show
  1. package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +322 -0
  2. package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +166 -0
  3. package/android/src/main/java/com/mapsindoorsrn/core/MPDisplayRuleModule.java +1699 -0
  4. package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +761 -0
  5. package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +410 -0
  6. package/android/src/main/java/com/mapsindoorsrn/core/RCMapView.java +16 -0
  7. package/android/src/main/java/com/mapsindoorsrn/core/README.md +3 -0
  8. package/android/src/main/java/com/mapsindoorsrn/core/UtilsModule.java +227 -0
  9. package/android/src/main/java/com/mapsindoorsrn/core/models/BitmapStopIconConfig.java +22 -0
  10. package/android/src/main/java/com/mapsindoorsrn/core/models/Bounds.java +19 -0
  11. package/android/src/main/java/com/mapsindoorsrn/core/models/Filter.java +77 -0
  12. package/android/src/main/java/com/mapsindoorsrn/core/models/Location.java +17 -0
  13. package/android/src/main/java/com/mapsindoorsrn/core/models/MPCameraPosition.java +34 -0
  14. package/android/src/main/java/com/mapsindoorsrn/core/models/MPCameraUpdate.java +68 -0
  15. package/android/src/main/java/com/mapsindoorsrn/core/models/MPError.java +38 -0
  16. package/android/src/main/java/com/mapsindoorsrn/core/models/PositionProvider.java +46 -0
  17. package/android/src/main/java/com/mapsindoorsrn/core/models/PositionResult.java +117 -0
  18. package/android/src/main/java/com/mapsindoorsrn/core/models/Query.java +30 -0
  19. package/android/src/main/java/com/mapsindoorsrn/core/models/RouteStopIconConfigModel.java +35 -0
  20. package/ios/core/CameraPosition.swift +15 -0
  21. package/ios/core/CameraUpdate.swift +19 -0
  22. package/ios/core/CameraUpdateError.swift +11 -0
  23. package/ios/core/DirectionsRendererBridge.m +59 -0
  24. package/ios/core/DirectionsRendererModule.swift +359 -0
  25. package/ios/core/DirectionsServiceBridge.m +55 -0
  26. package/ios/core/DirectionsServiceModule.swift +186 -0
  27. package/ios/core/IconStopUrl.swift +17 -0
  28. package/ios/core/LabelGraphic.swift +15 -0
  29. package/ios/core/MPDisplayRuleBridge.m +696 -0
  30. package/ios/core/MPDisplayRuleModule.swift +1704 -0
  31. package/ios/core/MapControlBridge.m +213 -0
  32. package/ios/core/MapControlModule.swift +702 -0
  33. package/ios/core/MapsIndoorsBridge.m +128 -0
  34. package/ios/core/MapsIndoorsData.swift +288 -0
  35. package/ios/core/MapsIndoorsModule.swift +363 -0
  36. package/ios/core/RCMapView.swift +16 -0
  37. package/ios/core/README.md +3 -0
  38. package/ios/core/ReactPositionProvider.swift +27 -0
  39. package/ios/core/RouteIcon.swift +34 -0
  40. package/ios/core/UtilsBridge.m +73 -0
  41. package/ios/core/UtilsModule.swift +182 -0
  42. package/ios/core/helpers.swift +57 -0
  43. package/package.json +1 -1
  44. package/src/core/EventNames.ts +21 -0
  45. package/src/core/MPAdditionalDetail.ts +102 -0
  46. package/src/core/MPBadgePosition.ts +12 -0
  47. package/src/core/MPBounds.ts +155 -0
  48. package/src/core/MPBuilding.ts +333 -0
  49. package/src/core/MPBuildingCollection.ts +57 -0
  50. package/src/core/MPBuildingInfo.ts +63 -0
  51. package/src/core/MPCameraEvent.ts +17 -0
  52. package/src/core/MPCameraEventListener.ts +17 -0
  53. package/src/core/MPCameraPosition.ts +82 -0
  54. package/src/core/MPCameraUpdate.ts +174 -0
  55. package/src/core/MPCameraViewFitMode.ts +25 -0
  56. package/src/core/MPCategory.ts +85 -0
  57. package/src/core/MPCategoryCollection.ts +62 -0
  58. package/src/core/MPCollection.ts +59 -0
  59. package/src/core/MPCollisionHandling.ts +12 -0
  60. package/src/core/MPDailyOpeningHours.ts +67 -0
  61. package/src/core/MPDataField.ts +69 -0
  62. package/src/core/MPDetailType.ts +73 -0
  63. package/src/core/MPDirectionsRenderer.ts +238 -0
  64. package/src/core/MPDirectionsService.ts +152 -0
  65. package/src/core/MPDisplayRule.ts +1823 -0
  66. package/src/core/MPEntity.ts +60 -0
  67. package/src/core/MPEntityInfo.ts +28 -0
  68. package/src/core/MPError.ts +122 -0
  69. package/src/core/MPFeatureTypes.ts +8 -0
  70. package/src/core/MPFilter.ts +168 -0
  71. package/src/core/MPFilterBehavior.ts +115 -0
  72. package/src/core/MPFloor.ts +170 -0
  73. package/src/core/MPFloorSelectorInterface.ts +63 -0
  74. package/src/core/MPGeometry.ts +91 -0
  75. package/src/core/MPHighlightBehavior.ts +115 -0
  76. package/src/core/MPHighway.ts +14 -0
  77. package/src/core/MPIconPlacement.ts +13 -0
  78. package/src/core/MPIconSize.ts +39 -0
  79. package/src/core/MPLabelGraphic.ts +24 -0
  80. package/src/core/MPLabelPosition.ts +12 -0
  81. package/src/core/MPLabelType.ts +11 -0
  82. package/src/core/MPLocation.ts +440 -0
  83. package/src/core/MPLocationPropertyNames.ts +30 -0
  84. package/src/core/MPLocationSettings.ts +40 -0
  85. package/src/core/MPLocationType.ts +16 -0
  86. package/src/core/MPMapConfig.ts +280 -0
  87. package/src/core/MPMapStyle.ts +57 -0
  88. package/src/core/MPMultiPolygon.ts +218 -0
  89. package/src/core/MPOpeningHours.ts +48 -0
  90. package/src/core/MPPOIType.ts +43 -0
  91. package/src/core/MPPoint.ts +169 -0
  92. package/src/core/MPPolygon.ts +219 -0
  93. package/src/core/MPPositionProviderInterface.ts +45 -0
  94. package/src/core/MPPositionResultInterface.ts +42 -0
  95. package/src/core/MPPropertyData.ts +234 -0
  96. package/src/core/MPQuery.ts +69 -0
  97. package/src/core/MPRoute.ts +105 -0
  98. package/src/core/MPRouteCoordinate.ts +95 -0
  99. package/src/core/MPRouteLeg.ts +158 -0
  100. package/src/core/MPRouteProperty.ts +83 -0
  101. package/src/core/MPRouteStep.ts +186 -0
  102. package/src/core/MPRouteStopIconConfig.ts +82 -0
  103. package/src/core/MPSelectionBehavior.ts +114 -0
  104. package/src/core/MPSelectionMode.ts +4 -0
  105. package/src/core/MPSettings3D.ts +107 -0
  106. package/src/core/MPSize.ts +21 -0
  107. package/src/core/MPSolution.ts +189 -0
  108. package/src/core/MPSolutionConfig.ts +188 -0
  109. package/src/core/MPSolutionDisplayRule.ts +15 -0
  110. package/src/core/MPUserRole.ts +60 -0
  111. package/src/core/MPUserRoleCollection.ts +37 -0
  112. package/src/core/MPUtils.ts +178 -0
  113. package/src/core/MPVenue.ts +294 -0
  114. package/src/core/MPVenueCollection.ts +58 -0
  115. package/src/core/MPVenueInfo.ts +62 -0
  116. package/src/core/MPWeeklyOpeningHours.ts +129 -0
  117. package/src/core/MapControl.ts +961 -0
  118. package/src/core/MapView.tsx +34 -0
  119. package/src/core/MapsIndoors.ts +571 -0
  120. package/src/core/OnBuildingFoundAtCameraTargetListener.ts +17 -0
  121. package/src/core/OnFloorSelectionChangedListener.ts +17 -0
  122. package/src/core/OnFloorUpdateListener.ts +16 -0
  123. package/src/core/OnLegSelectedListener.ts +17 -0
  124. package/src/core/OnLiveLocationUpdateListener.ts +17 -0
  125. package/src/core/OnLocationSelectedListener.ts +17 -0
  126. package/src/core/OnMapClickListener.ts +20 -0
  127. package/src/core/OnMarkerClickListener.ts +17 -0
  128. package/src/core/OnMarkerInfoWindowClickListener.ts +17 -0
  129. package/src/core/OnPositionUpdateListener.ts +17 -0
  130. package/src/core/OnVenueFoundAtCameraTargetListener.ts +17 -0
  131. package/src/core/README.md +3 -0
  132. package/src/core/RouteStopIconConfig.ts +10 -0
@@ -0,0 +1,182 @@
1
+ //
2
+ // UtilsModule.swift
3
+ // react-native-maps-indoors
4
+ //
5
+ // Created by Tim Mikkelsen on 26/04/2023.
6
+ //
7
+
8
+ import Foundation
9
+ import MapsIndoors
10
+ import MapsIndoorsCore
11
+
12
+ @objc(UtilsModule)
13
+ public class UtilsModule: NSObject {
14
+
15
+ @objc public static func requiresMainQueueSetup() -> Bool {return false}
16
+
17
+ @objc public func venueHasGraph(_ venueId: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
18
+ Task {
19
+ guard let venue = await MPMapsIndoors.shared.venueWith(id: venueId) else {
20
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
21
+ }
22
+
23
+ return resolve(venue.hasGraph)
24
+ }
25
+ }
26
+
27
+ @objc public func pointAngleBetween(_ point1: String, point2: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
28
+
29
+ guard let it = try? JSONDecoder().decode(MPPoint.self, from: Data(point1.utf8)) as MPPoint else {
30
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
31
+ }
32
+
33
+ guard let other = try? JSONDecoder().decode(MPPoint.self, from: Data(point2.utf8)) as MPPoint else {
34
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
35
+ }
36
+
37
+ return resolve(MPGeometryUtils.bearingBetweenPoints(from: it.coordinate, to: other.coordinate))
38
+ }
39
+
40
+ @objc public func pointDistanceTo(_ point1: String, point2: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
41
+ guard let it = try? JSONDecoder().decode(MPPoint.self, from: Data(point1.utf8)) as MPPoint else {
42
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
43
+ }
44
+
45
+ guard let other = try? JSONDecoder().decode(MPPoint.self, from: Data(point2.utf8)) as MPPoint else {
46
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
47
+ }
48
+
49
+ return resolve(MPGeometryUtils.distance(from: MPGeoPoint(coordinate: it.coordinate), to: MPGeoPoint(coordinate: other.coordinate)))
50
+ }
51
+
52
+ @objc public func geometryIsInside(_ point: String, geometry: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
53
+ guard let it = try? JSONDecoder().decode(MPPoint.self, from: Data(point.utf8)) as MPPoint else {
54
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
55
+ }
56
+
57
+ guard let geo = try? JSONDecoder().decode(MPGeometry.self, from: Data(geometry.utf8)) as MPGeometry else {
58
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
59
+ }
60
+
61
+ if (geo is MPPolygonGeometry) {
62
+ let poly = geo.mp_polygon
63
+ return resolve(poly?.containsCoordinate(it.coordinate))
64
+ }else if (geo is MPMultiPolygonGeometry) {
65
+ let multiPoly = geo.mp_multiPolygon
66
+ resolve(multiPoly?.containsCoordinate(it.coordinate))
67
+ }else {
68
+ resolve(false)
69
+ }
70
+ }
71
+
72
+ @objc public func geometryArea(_ geometry: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
73
+
74
+ guard let geo = try? JSONDecoder().decode(MPGeometry.self, from: Data(geometry.utf8)) as MPGeometry else {
75
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
76
+ }
77
+
78
+ if (geo is MPPolygonGeometry) {
79
+ let poly = geo.mp_polygon
80
+ return resolve(poly?.area)
81
+ }else if (geo is MPMultiPolygonGeometry) {
82
+ let multiPoly = geo.mp_multiPolygon
83
+ return resolve(multiPoly?.area)
84
+ }else {
85
+ return resolve(0)
86
+ }
87
+ }
88
+
89
+ @objc public func polygonDistanceToClosestEdge(_ point: String, geometry: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
90
+
91
+ guard let it = try? JSONDecoder().decode(MPPoint.self, from: Data(point.utf8)) as MPPoint else {
92
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
93
+ }
94
+
95
+ guard let geo = try? JSONDecoder().decode(MPGeometry.self, from: Data(geometry.utf8)) as MPGeometry else {
96
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
97
+ }
98
+
99
+ if(geo is MPPolygonGeometry){
100
+
101
+ guard let outerRing = (geo.mp_polygon.coordinates.first?.map {CLLocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude)}) else {
102
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
103
+ }
104
+
105
+ var shortestDistance = Double.greatestFiniteMagnitude
106
+ for i in 1 ..< outerRing.count {
107
+ let p1 = outerRing[i-1]
108
+ let p2 = outerRing[i]
109
+
110
+ let distanceToLine = MPGeometryUtils.distancePointToLine(point: it.coordinate, lineStart: p1, lineEnd: p2)
111
+ if( distanceToLine < shortestDistance) {
112
+ shortestDistance = distanceToLine
113
+ }
114
+ }
115
+
116
+ return resolve(shortestDistance)
117
+ }
118
+ return resolve(nil)
119
+ }
120
+
121
+ @objc public func parseMapClientUrl(_ venueId: String, locationId: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
122
+ return resolve(MPMapsIndoors.shared.solution?.getMapClientUrlFor(venueId: venueId, locationId: locationId))
123
+ }
124
+
125
+ @objc public func setCollisionHandling(_ collisionHandling: NSNumber, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
126
+ guard let collision = MPCollisionHandling.init(rawValue: collisionHandling.intValue) else {
127
+ return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
128
+ }
129
+ MPMapsIndoors.shared.solution?.config.collisionHandling = collision
130
+ return resolve(nil)
131
+ }
132
+
133
+ @objc public func enableClustering(_ enableClustering: Bool, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
134
+ MPMapsIndoors.shared.solution?.config.enableClustering = enableClustering
135
+ return resolve(nil)
136
+ }
137
+
138
+ @objc public func setExtrusionOpacity(_ opacity: Double, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
139
+ MPMapsIndoors.shared.solution?.config.settings3D.extrusionOpacity = opacity
140
+ return resolve(nil)
141
+ }
142
+
143
+ @objc public func setWallOpacity(_ opacity: Double, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
144
+ MPMapsIndoors.shared.solution?.config.settings3D.wallOpacity = opacity
145
+ return resolve(nil)
146
+ }
147
+
148
+ @objc public func setNewSelection(_ isNewSelection: Bool, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
149
+ MPMapsIndoors.shared.solution?.config.newSelection = isNewSelection
150
+ return resolve(nil)
151
+ }
152
+
153
+ @objc public func setSelectable(_ settingsId: String, value: Bool, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
154
+ if (settingsId == "solution") {
155
+ MPMapsIndoors.shared.solution?.config.locationSettings.selectable = value
156
+ } else {
157
+ if let location = MPMapsIndoors.shared.locationWith(locationId: settingsId) {
158
+ if location.locationSettings == nil {
159
+ location.locationSettings = MPLocationSettings()
160
+ }
161
+ location.locationSettings?.selectable = value
162
+ } else {
163
+ if let type = MPMapsIndoors.shared.solution?.types.first(where: {$0.name == settingsId}) {
164
+ if type.locationSettings == nil {
165
+ type.locationSettings = MPLocationSettings()
166
+ }
167
+ type.locationSettings?.selectable = value
168
+ }
169
+ }
170
+ }
171
+ return resolve(nil)
172
+ }
173
+
174
+ @objc public func setAutomatedZoomLimit(_ value: Double, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
175
+ if value == -1 {
176
+ MPMapsIndoors.shared.solution?.config.automatedZoomLimit = nil
177
+ } else {
178
+ MPMapsIndoors.shared.solution?.config.automatedZoomLimit = value
179
+ }
180
+ return resolve(nil)
181
+ }
182
+ }
@@ -0,0 +1,57 @@
1
+ import MapsIndoors
2
+
3
+ struct ErrorObject: Codable {
4
+ var code: MPError
5
+ var message: String
6
+
7
+ public func asJSON() -> String {
8
+ toJSON(self)
9
+ }
10
+ }; extension ErrorObject { // Don't want to lose default initializer, so this must be in an extension
11
+ init(from mpError: MPError) {
12
+ code = mpError
13
+ message = String(describing: mpError)
14
+ }
15
+ }
16
+
17
+ public func toJSON<T:Encodable>(_ object: T) -> String {
18
+ let encoder = JSONEncoder()
19
+ let jsonData = try! encoder.encode(object)
20
+ let jsonStr = String(data: jsonData, encoding: .utf8)!
21
+ return jsonStr
22
+ }
23
+
24
+ /// Provide 'type: YourType.self' if the type cannot be inferred from the type of the parameter or variable it will be used in
25
+ public func fromJSON<T:Decodable>(_ jsonString: String, type _: T.Type = T.self) throws -> T {
26
+ let decoder = JSONDecoder()
27
+ let result = try decoder.decode(T.self, from: jsonString.data(using: .utf8)!)
28
+ return result
29
+ }
30
+
31
+ private func fileToClassName(_ file: String) -> String {
32
+ return file
33
+ .split(separator: "/").last?
34
+ .split(separator: ".").first
35
+ .map{String($0)} ?? file
36
+ }
37
+
38
+ private func parsePrefix(file: String, func _func: String, line: Int, col: Int) -> String {
39
+ let className = fileToClassName(file)
40
+ let funcName: String = _func.split(separator: "(").first.map{String($0)} ?? _func
41
+ return "\(className).\(funcName):\(line):\(col)"
42
+ }
43
+
44
+ public func doReject(_ reject: RCTPromiseRejectBlock, message: String,
45
+ _file: String = #fileID, _func: String = #function, _line: Int = #line, _col: Int = #column) {
46
+ let prefix = parsePrefix(file: _file, func: _func, line: _line, col: _col)
47
+ let err = ErrorObject(code: .unknownError, message: "[\(prefix)] \(message)")
48
+ return reject("NativeError", toJSON(err), err.code)
49
+ }
50
+
51
+ public func doReject(_ reject: RCTPromiseRejectBlock, error: Error,
52
+ _file: String = #fileID, _func: String = #function, _line: Int = #line, _col: Int = #column) {
53
+ let prefix = parsePrefix(file: _file, func: _func, line: _line, col: _col)
54
+ let err = ErrorObject(code: .unknownError, message: "[\(prefix)] \(error)")
55
+ return reject("NativeError", toJSON(err), error)
56
+ }
57
+
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": "2.6.1",
4
+ "version": "2.6.2-rc.1",
5
5
  "description": "React Native MapsIndoors component with mapbox",
6
6
  "react-native": "index.ts",
7
7
  "files": [
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A list of event aliases used internally by the MapsIndoors React Native Bindings to keep track of SDK events.
3
+ *
4
+ * @export
5
+ * @enum {number}
6
+ */
7
+ export enum EventNames {
8
+ cameraEvent = "cameraEvent",
9
+ onFloorSelectionChanged = "onFloorSelectionChanged",
10
+ onFloorUpdate = "onFloorUpdate",
11
+ onLocationSelected = "onLocationSelected",
12
+ onMapClick = "onMapClick",
13
+ onPositionUpdate = "onPositionUpdate",
14
+ onVenueFoundAtCameraTarget = "onVenueFoundAtCameraTarget",
15
+ onBuildingFoundAtCameraTarget = "onBuildingFoundAtCameraTarget",
16
+ onMarkerClick = "onMarkerClick",
17
+ onInfoWindowClick = "onInfoWindowClick",
18
+ onLiveLocationUpdate = "onLiveLocationUpdate",
19
+ floorSelector = "floorSelector",
20
+ onLegSelected = "onLegSelected",
21
+ }
@@ -0,0 +1,102 @@
1
+ import { MPDetailType } from './MPDetailType';
2
+ import { MPOpeningHours } from './MPOpeningHours';
3
+
4
+ /**
5
+ * Represents additional details associated with a MapIndoors entity, such as a location or a point of interest.
6
+ * This class contains various fields that provide information about the additional details.
7
+ */
8
+ export class MPAdditionalDetail {
9
+ /**
10
+ * The type of detail, e.g. "phone", "email", "website", etc.
11
+ */
12
+ private _detailType: MPDetailType | null = null;
13
+
14
+ /**
15
+ * The key for the additional detail, which is typically a string identifier.
16
+ */
17
+ private _key: string | null = null;
18
+
19
+ /**
20
+ * The value of the additional detail, which can be a string representing
21
+ */
22
+ private _value: string | null = null;
23
+
24
+ /**
25
+ * The icon associated with the additional detail, which is a URL.
26
+ */
27
+ private _icon: string | null = null;
28
+
29
+ /**
30
+ * The display text for the additional detail, which is a localized user-friendly string.
31
+ */
32
+ private _displayText: string | null = null;
33
+
34
+ /**
35
+ * Indicates whether the additional detail is active or not.
36
+ */
37
+ private _active: boolean | null = null;
38
+
39
+ /**
40
+ * The opening hours associated with the additional detail, represented by an MPOpeningHours object.
41
+ */
42
+ private _openingHours: MPOpeningHours | null = null;
43
+
44
+ get detailType(): MPDetailType | null {
45
+ return this._detailType;
46
+ }
47
+
48
+ get key(): string | null {
49
+ return this._key;
50
+ }
51
+
52
+ get value(): string | null {
53
+ return this._value;
54
+ }
55
+
56
+ get icon(): string | null {
57
+ return this._icon;
58
+ }
59
+
60
+ get displayText(): string | null {
61
+ return this._displayText;
62
+ }
63
+
64
+ get active(): boolean | null {
65
+ return this._active;
66
+ }
67
+
68
+ get openingHours(): MPOpeningHours | null {
69
+ return this._openingHours;
70
+ }
71
+
72
+ /**
73
+ * Creates an instance of MPAdditionalDetail from a JSON object.
74
+ */
75
+ static fromJson(json: any): MPAdditionalDetail {
76
+ const detail = new MPAdditionalDetail();
77
+ detail._detailType = json.detailType || null;
78
+ detail._key = json.key || null;
79
+ detail._value = json.value || null;
80
+ detail._icon = json.icon || null;
81
+ detail._displayText = json.displayText || null;
82
+ detail._active = json.active || null;
83
+ detail._openingHours = json.openingHours || null;
84
+ return detail;
85
+ }
86
+
87
+ /**
88
+ * Converts the instance to a JSON object.
89
+ * This is useful for serialization.
90
+ */
91
+ toJson(): any {
92
+ return {
93
+ detailType: this._detailType,
94
+ key: this._key,
95
+ value: this._value,
96
+ icon: this._icon,
97
+ displayText: this._displayText,
98
+ active: this._active,
99
+ openingHours: this._openingHours,
100
+ };
101
+ }
102
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The possible position of the badge on an icon.
3
+ *
4
+ * @export
5
+ * @enum {number}
6
+ */
7
+ export enum MPBadgePosition {
8
+ bottomLeft,
9
+ bottomRight,
10
+ topLeft,
11
+ topRight,
12
+ }
@@ -0,0 +1,155 @@
1
+ import MPPoint from "./MPPoint";
2
+ import { Platform } from "react-native";
3
+
4
+ /**
5
+ * A simple representation of a bounding box.
6
+ *
7
+ * @export
8
+ * @class MPBounds
9
+ * @typedef {MPBounds}
10
+ */
11
+ export default class MPBounds {
12
+ /**
13
+ * Creates an instance of MPBounds.
14
+ *
15
+ * @constructor
16
+ * @public
17
+ * @param {MPPoint} northeast The northeastern most point.
18
+ * @param {MPPoint} southwest The southwestern most point.
19
+ */
20
+ public constructor(
21
+ public readonly northeast: MPPoint,
22
+ public readonly southwest: MPPoint) {
23
+ this.northeast = northeast;
24
+ this.southwest = southwest;
25
+ }
26
+
27
+ /**
28
+ * Creator for MPBounds, used to decode JSON from the MapsIndoors SDK.
29
+ *
30
+ * @public
31
+ * @static
32
+ * @param {MPBoundsParams} object
33
+ * @returns {MPBounds}
34
+ */
35
+ public static create(object: MPBoundsParams): MPBounds {
36
+ var bounds;
37
+ if ((object as any).northeast.lat != null) {
38
+ var northeast = new MPPoint((object as any).northeast.lat, (object as any).northeast.lng, (object as any).northeast.zLevel);
39
+ var southwest = new MPPoint((object as any).southwest.lat, (object as any).southwest.lng, (object as any).southwest.zLevel);
40
+ bounds = new MPBounds(northeast, southwest)
41
+ }else {
42
+ bounds = new MPBounds(
43
+ object.northeast,
44
+ object.southwest,
45
+ );
46
+ }
47
+ return bounds
48
+ }
49
+
50
+ /**
51
+ * Create a MPBounds from a Bounding Box.
52
+ *
53
+ * @public
54
+ * @static
55
+ * @param {number[]} bbox
56
+ * @returns {MPBounds}
57
+ */
58
+ public static fromBBox(bbox: number[]): MPBounds {
59
+ return new MPBounds(
60
+ new MPPoint(bbox[3], bbox[2]),
61
+ new MPPoint(bbox[1], bbox[0]),
62
+ );
63
+ }
64
+
65
+ /**
66
+ * The center of the bounds.
67
+ *
68
+ * @public
69
+ * @readonly
70
+ * @type {MPPoint}
71
+ */
72
+ public get center(): MPPoint {
73
+ let latCenter = (this.northeast.latitude + this.southwest.latitude) / 2;
74
+ let lngCenter = (this.northeast.longitude + this.southwest.longitude) / 2;
75
+ return new MPPoint(latCenter, lngCenter);
76
+ }
77
+
78
+ /**
79
+ * Check whether a point is containted within the bounds.
80
+ *
81
+ * @public
82
+ * @param {MPPoint} point
83
+ * @returns {boolean}
84
+ */
85
+ public contains(point: MPPoint): boolean {
86
+ return ((point.latitude <= this.northeast.latitude &&
87
+ point.latitude >= this.southwest.latitude)) &&
88
+ ((point.longitude <= this.northeast.longitude &&
89
+ point.longitude >= this.southwest.longitude));
90
+ }
91
+
92
+
93
+ public toJSON() {
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
+ }
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Construct a bounds object from a collection of points, to ensure that the bounds contains all of them.
109
+ *
110
+ * @class
111
+ */
112
+ public static Builder = class {
113
+ public north = Number.NEGATIVE_INFINITY;
114
+ public south = Number.POSITIVE_INFINITY;
115
+ public east = Number.NEGATIVE_INFINITY;
116
+ public west = Number.POSITIVE_INFINITY;
117
+
118
+ public include(point: MPPoint) {
119
+ this.north = Math.max(this.north, point.latitude);
120
+ this.south = Math.min(this.south, point.latitude);
121
+ this.east = Math.max(this.east, point.longitude);
122
+ this.west = Math.min(this.west, point.longitude);
123
+ }
124
+
125
+ public build(): MPBounds {
126
+ if (this.north == Number.POSITIVE_INFINITY) {
127
+ throw Error("Cannot build bounds with no coordinates");
128
+ }
129
+
130
+ return new MPBounds(new MPPoint(this.north, this.east), new MPPoint(this.south, this.west));
131
+ }
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Parameter interface for {@link MPBounds}.
137
+ *
138
+ * @export
139
+ * @interface MPBoundsParams
140
+ * @typedef {MPBoundsParams}
141
+ */
142
+ export interface MPBoundsParams {
143
+ /**
144
+ * A point.
145
+ *
146
+ * @type {MPPoint}
147
+ */
148
+ southwest: MPPoint;
149
+ /**
150
+ * A point.
151
+ *
152
+ * @type {MPPoint}
153
+ */
154
+ northeast: MPPoint;
155
+ }