@mapsindoors/react-native-maps-indoors-mapbox 1.3.2 → 2.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 (44) hide show
  1. package/README.md +48 -1
  2. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  3. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  4. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  5. package/android/.idea/compiler.xml +1 -1
  6. package/android/.idea/gradle.xml +1 -1
  7. package/android/.idea/misc.xml +2 -1
  8. package/android/build.gradle +2 -2
  9. package/android/src/main/java/com/mapsindoorsrn/MapboxMapView.java +12 -2
  10. package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsViewManager.java +5 -1
  11. package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +3 -0
  12. package/android/src/main/java/com/mapsindoorsrn/core/MPDisplayRuleModule.java +172 -0
  13. package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +80 -0
  14. package/android/src/main/java/com/mapsindoorsrn/core/UtilsModule.java +39 -0
  15. package/app.plugin.js +280 -0
  16. package/index.ts +12 -1
  17. package/ios/MapsIndoorsViewManager.swift +21 -4
  18. package/ios/core/DirectionsRendererModule.swift +2 -0
  19. package/ios/core/LabelGraphic.swift +15 -0
  20. package/ios/core/MPDisplayRuleBridge.m +81 -0
  21. package/ios/core/MPDisplayRuleModule.swift +191 -0
  22. package/ios/core/MapControlBridge.m +21 -0
  23. package/ios/core/MapControlModule.swift +83 -1
  24. package/ios/core/RCMapView.swift +1 -1
  25. package/ios/core/UtilsBridge.m +4 -0
  26. package/ios/core/UtilsModule.swift +21 -0
  27. package/package.json +3 -2
  28. package/react-native-maps-indoors-mapbox.podspec +2 -2
  29. package/src/core/MPCameraViewFitMode.ts +4 -0
  30. package/src/core/MPDirectionsRenderer.ts +6 -1
  31. package/src/core/MPDisplayRule.ts +296 -89
  32. package/src/core/MPFeatureTypes.ts +8 -0
  33. package/src/core/MPLabelGraphic.ts +24 -0
  34. package/src/core/MPLabelType.ts +1 -0
  35. package/src/core/MPLocation.ts +20 -0
  36. package/src/core/MPLocationSettings.ts +40 -0
  37. package/src/core/MPMapConfig.ts +36 -0
  38. package/src/core/MPPOIType.ts +43 -0
  39. package/src/core/MPPropertyData.ts +10 -1
  40. package/src/core/MPSelectionMode.ts +4 -0
  41. package/src/core/MPSolution.ts +9 -0
  42. package/src/core/MPSolutionConfig.ts +18 -0
  43. package/src/core/MPUtils.ts +5 -0
  44. package/src/core/MapControl.ts +54 -0
@@ -0,0 +1,24 @@
1
+ export default class MPLabelGraphic {
2
+ private constructor(
3
+ public readonly backgroundImage: string,
4
+ public readonly stretchX: number[][],
5
+ public readonly stretchY: number[][],
6
+ public readonly content: number[]
7
+ ) { }
8
+
9
+ public static create(object: MPLabelGraphicParams): MPLabelGraphic {
10
+ return new MPLabelGraphic(
11
+ object.backgroundImage,
12
+ object.stretchX,
13
+ object.stretchY,
14
+ object.content,
15
+ );
16
+ }
17
+ }
18
+
19
+ export interface MPLabelGraphicParams {
20
+ backgroundImage: string;
21
+ stretchX: number[][];
22
+ stretchY: number[][];
23
+ content: number[];
24
+ }
@@ -7,4 +7,5 @@
7
7
  export enum MPLabelType {
8
8
  flat,
9
9
  floating,
10
+ graphic
10
11
  }
@@ -2,6 +2,7 @@ import { Platform } from "react-native";
2
2
  import { MPGeometry, MPPoint, MPPolygon, MPBuilding, MPVenue, MPMultiPolygon, MPBounds, MPLocationType, MPLocationPropertyNames } from "../../index";
3
3
  import MPEntity from "./MPEntity";
4
4
  import MPPropertyData from "./MPPropertyData";
5
+ import MPLocationSettings from "./MPLocationSettings";
5
6
 
6
7
  /**
7
8
  * A MapsIndoors geographical entity. A location can exist anywhere,
@@ -283,6 +284,25 @@ export default class MPLocation extends MPEntity {
283
284
  return this.properties?.bookable ? this.properties.bookable : false;
284
285
  }
285
286
 
287
+ /**
288
+ * Set the location's selectable flag.
289
+ */
290
+ set selectable(selectable: boolean | undefined) {
291
+ if (this.properties?.locationSettings) {
292
+ this.properties.locationSettings.selectable = selectable;
293
+ }else if (this.properties) {
294
+ this.properties.locationSettings = MPLocationSettings.create(this.name, { selectable });
295
+ this.properties.locationSettings.selectable = selectable;
296
+ }
297
+ }
298
+
299
+ /**
300
+ * Get the location's selectable flag.
301
+ */
302
+ get selectable(): boolean | null {
303
+ return this.properties?.locationSettings?.selectable ?? null;
304
+ }
305
+
286
306
  /**
287
307
  * Get the location's basetype.
288
308
  *
@@ -0,0 +1,40 @@
1
+ import MPUtils from "./MPUtils";
2
+
3
+ export default class MPLocationSettings {
4
+ /**
5
+ * @constructor
6
+ * @private
7
+ * @param selectable
8
+ */
9
+ private constructor(
10
+ readonly id: string,
11
+ private _selectable?: boolean,
12
+ ) {}
13
+
14
+ /**
15
+ * Creator for MPLocationSettings, used to decode JSON from the MapsIndoors SDK.
16
+ *
17
+ * @static
18
+ * @param {MPLocationSettingsParams} object
19
+ * @returns {MPLocationSettings}
20
+ */
21
+ public static create(id: string, object: MPLocationSettingsParams): MPLocationSettings {
22
+ return new MPLocationSettings(
23
+ id,
24
+ object?.selectable,
25
+ );
26
+ }
27
+
28
+ set selectable(selectable: boolean | undefined) {
29
+ this._selectable = selectable;
30
+ MPUtils.setSelectable(this.id, selectable);
31
+ }
32
+
33
+ get selectable(): boolean | undefined {
34
+ return this._selectable;
35
+ }
36
+ }
37
+
38
+ export interface MPLocationSettingsParams {
39
+ selectable?: boolean;
40
+ }
@@ -96,6 +96,26 @@ export default class MPMapConfig {
96
96
  */
97
97
  public readonly floorSelector?: MPFloorSelectorInterface;
98
98
 
99
+ /**
100
+ * The zoom level at which the map should transition to MapsIndoors tiles. Mapbox specific.
101
+ *
102
+ * The default value is 17.
103
+ * @public
104
+ * @readonly
105
+ * @type {?number}
106
+ */
107
+ public readonly mapsIndoorsTransitionLevel?: number;
108
+
109
+ /**
110
+ * Whether to show the mapbox markers on the map. Includes POI's and Places.
111
+ * Mapbox specific
112
+ * The default value is undefined, and enables/disables based on the transition zoom level.
113
+ * @public
114
+ * @readonly
115
+ * @type {?boolean}
116
+ */
117
+ public readonly showMapMarkers?: boolean;
118
+
99
119
  /**
100
120
  * Creates an instance of MPMapConfig.
101
121
  *
@@ -114,6 +134,8 @@ export default class MPMapConfig {
114
134
  this.showUserPosition = params.showUserPosition;
115
135
  this.enableTileFadeIn = params.enableTileFadeIn;
116
136
  this.floorSelector = params.floorSelector;
137
+ this.mapsIndoorsTransitionLevel = params.mapsIndoorsTransitionLevel;
138
+ this.showMapMarkers = params.showMapMarkers;
117
139
  }
118
140
  }
119
141
 
@@ -208,4 +230,18 @@ export interface MPMapConfigParams {
208
230
  * @type {?MPFloorSelectorInterface}
209
231
  */
210
232
  floorSelector?: MPFloorSelectorInterface,
233
+ /**
234
+ * The zoom level at which the map should transition to MapsIndoors tiles. Mapbox specific.
235
+ *
236
+ * The default value is 17.
237
+ * @type {?number}
238
+ */
239
+ mapsIndoorsTransitionLevel?: number,
240
+ /**
241
+ * Whether to show the mapbox markers on the map. Includes POI's and Places.
242
+ * Mapbox specific
243
+ * The default value is undefined, and enables/disables based on the transition zoom level.
244
+ * @type {?boolean}
245
+ */
246
+ showMapMarkers?: boolean,
211
247
  }
@@ -0,0 +1,43 @@
1
+ import MPLocationSettings from "./MPLocationSettings";
2
+
3
+ export default class MPPOIType {
4
+ private constructor(
5
+ public readonly name: string,
6
+ public readonly translatedName: string,
7
+ private locationSettings?: MPLocationSettings,
8
+ ) { }
9
+
10
+ public static create(object: MPPOITypeParams): MPPOIType {
11
+ return new MPPOIType(
12
+ object.name,
13
+ object.translatedName,
14
+ object.locationSettings ? MPLocationSettings.create(object.name, object.locationSettings) : undefined,
15
+ );
16
+ }
17
+
18
+ /**
19
+ * Set the selectable flag for the POI type.
20
+ */
21
+ set selectable(selectable: boolean | null) {
22
+ if (this.locationSettings) {
23
+ this.locationSettings.selectable = selectable;
24
+ }else {
25
+ this.locationSettings = MPLocationSettings.create(this.name, { selectable });
26
+ this.locationSettings.selectable = selectable;
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Get the selectable flag for the POI type.
32
+ */
33
+ get selectable(): boolean | null {
34
+ return this.locationSettings?.selectable ?? null;
35
+ }
36
+
37
+ }
38
+
39
+ export interface MPPOITypeParams {
40
+ name: string;
41
+ translatedName: string;
42
+ locationSettings?: MPLocationSettings;
43
+ }
@@ -1,6 +1,7 @@
1
1
  import { Platform } from "react-native";
2
2
  import { MPPoint, MPDataField, MPPointParams } from "../../index";
3
3
  import { MPEntityInfo } from "./MPEntityInfo";
4
+ import MPLocationSettings from "./MPLocationSettings";
4
5
 
5
6
  /**
6
7
  * Internal - Documentation will follow.
@@ -55,6 +56,7 @@ export default class MPPropertyData extends MPEntityInfo {
55
56
  readonly locationType?: string,
56
57
  readonly bookable?: boolean,
57
58
  readonly anchor?: MPPoint,
59
+ public locationSettings?: MPLocationSettings,
58
60
  ) { super(name, aliases, fields, undefined) }
59
61
 
60
62
  /**
@@ -65,7 +67,7 @@ export default class MPPropertyData extends MPEntityInfo {
65
67
  * @param {MPPropertyDataParams} object
66
68
  * @returns {MPPropertyData}
67
69
  */
68
- public static create(object: MPPropertyDataParams): MPPropertyData {
70
+ public static create(object: MPPropertyDataParams, id?: string): MPPropertyData {
69
71
  var floor;
70
72
  if (Platform.OS === 'ios') {
71
73
  floor = object?.floor as number;
@@ -92,6 +94,7 @@ export default class MPPropertyData extends MPEntityInfo {
92
94
  object?.locationType,
93
95
  object?.bookable,
94
96
  MPPoint.create(object?.anchor),
97
+ object?.locationSettings && id ? MPLocationSettings.create(id, object?.locationSettings) : undefined,
95
98
  );
96
99
  }
97
100
  }
@@ -212,4 +215,10 @@ export interface MPPropertyDataParams {
212
215
  * @type {?MPPointParams}
213
216
  */
214
217
  anchor?: MPPointParams,
218
+ /**
219
+ * Internal - Documentation will follow.
220
+ *
221
+ * @type {?MPLocationSettings}
222
+ */
223
+ locationSettings?: MPLocationSettings,
215
224
  }
@@ -0,0 +1,4 @@
1
+ export enum MPSelectionMode {
2
+ manual,
3
+ automatic
4
+ }
@@ -1,4 +1,5 @@
1
1
  import { MPSolutionConfig } from "../../index";
2
+ import MPPOIType from "./MPPOIType";
2
3
  import MPUtils from "./MPUtils";
3
4
 
4
5
  /**
@@ -35,6 +36,7 @@ export default class MPSolution {
35
36
  public readonly locationTemplates?: string,
36
37
  public readonly customerId?: string,
37
38
  public mapClientUrl?: string,
39
+ public readonly types?: MPPOIType[]
38
40
  ) { }
39
41
 
40
42
 
@@ -57,6 +59,7 @@ export default class MPSolution {
57
59
  object?.locationTemplates,
58
60
  object?.customerId,
59
61
  object?.mapClientUrl,
62
+ object?.types?.map((type: any) => MPPOIType.create(type)),
60
63
  );
61
64
  }
62
65
 
@@ -171,6 +174,12 @@ export interface MPSolutionParams {
171
174
  * @type {?string}
172
175
  */
173
176
  locationTemplates?: string;
177
+ /**
178
+ * The solution's POI types.
179
+ *
180
+ * @type {?MPPOIType[]}
181
+ */
182
+ types?: MPPOIType[];
174
183
  /**
175
184
  * An array of modules that define some behaviors of the SDK set through the CMS.
176
185
  *
@@ -1,4 +1,5 @@
1
1
  import { MPCollisionHandling, MPSettings3D } from "../../index";
2
+ import MPLocationSettings from "./MPLocationSettings";
2
3
  import MPUtils from "./MPUtils";
3
4
 
4
5
  /**
@@ -27,6 +28,7 @@ export default class MPSolutionConfig {
27
28
  private constructor(
28
29
  public readonly id: string,
29
30
  public readonly settings3D: MPSettings3D,
31
+ public readonly locationSettings: MPLocationSettings,
30
32
  private _enableClustering?: boolean,
31
33
  private _mpCollisionHandling?: MPCollisionHandling,
32
34
  private _isNewSelection?: boolean,
@@ -45,6 +47,7 @@ export default class MPSolutionConfig {
45
47
  return new MPSolutionConfig(
46
48
  object?.id,
47
49
  MPSettings3D.create(object?.settings3D),
50
+ MPLocationSettings.create("solution", object?.locationSettings),
48
51
  object?.enableClustering,
49
52
  object?.collisionHandling,
50
53
  object?.isNewSelection,
@@ -101,6 +104,14 @@ export default class MPSolutionConfig {
101
104
  public get isNewSelection(): boolean {
102
105
  return this._isNewSelection ? this._isNewSelection : true;
103
106
  }
107
+
108
+ public get selectable(): boolean | undefined {
109
+ return this.locationSettings.selectable;
110
+ }
111
+
112
+ public set selectable(selectable: boolean | undefined) {
113
+ this.locationSettings.selectable = selectable;
114
+ }
104
115
  }
105
116
 
106
117
  /**
@@ -141,4 +152,11 @@ export interface MPSolutionConfigParams {
141
152
  * @type {?boolean}
142
153
  */
143
154
  isNewSelection?: boolean,
155
+
156
+ /**
157
+ * Location settings
158
+ *
159
+ * @type {MPLocationSettings}
160
+ */
161
+ locationSettings: MPLocationSettings,
144
162
  }
@@ -166,4 +166,9 @@ export default class MPUtils {
166
166
  static async setWallOpacity(opacity: number): Promise<void> {
167
167
  return UtilsModule.setWallOpacity(opacity);
168
168
  }
169
+
170
+ static async setSelectable(id: string, selectable: boolean): Promise<void> {
171
+ return UtilsModule.setSelectable(id, selectable);
172
+ }
173
+
169
174
  }
@@ -10,6 +10,8 @@ import {
10
10
  } from "../../index"
11
11
  import { EventNames } from './EventNames';
12
12
  import MPHighlightBehavior from './MPHighlightBehavior';
13
+ import { MPSelectionMode } from './MPSelectionMode';
14
+ import { MPFeatureType } from './MPFeatureTypes';
13
15
 
14
16
 
15
17
  const { MapControlModule } = NativeModules;
@@ -901,4 +903,56 @@ export default class MapControl {
901
903
  }
902
904
  return MapControlModule.setLabelOptions(textSize, color, showHalo).then(() => Promise.resolve());
903
905
  }
906
+
907
+ /**
908
+ * Set the selection mode for buildings.
909
+ *
910
+ * @public
911
+ * @param selectionMode
912
+ */
913
+ public setBuildingSelectionMode(selectionMode: MPSelectionMode): Promise<void> {
914
+ return MapControlModule.setBuildingSelectionMode(selectionMode);
915
+ }
916
+
917
+ /**
918
+ * Get the selection mode for buildings.
919
+ *
920
+ * @public
921
+ */
922
+ public getBuildingSelectionMode(): Promise<MPSelectionMode> {
923
+ return MapControlModule.getBuildingSelectionMode();
924
+ }
925
+
926
+ /**
927
+ * Set the selection mode for floors.
928
+ *
929
+ * @public
930
+ * @param selectionMode
931
+ */
932
+ public setFloorSelectionMode(selectionMode: MPSelectionMode): Promise<void> {
933
+ return MapControlModule.setFloorSelectionMode(selectionMode);
934
+ }
935
+
936
+ /**
937
+ * Get the selection mode for floors.
938
+ *
939
+ * @public
940
+ */
941
+ public getFloorSelectionMode(): Promise<MPSelectionMode> {
942
+ return MapControlModule.getFloorSelectionMode();
943
+ }
944
+
945
+ /**
946
+ * Set features to hide on the map.
947
+ */
948
+ public setHiddenFeatures(features: MPFeatureType[]): Promise<void> {
949
+ return MapControlModule.setHiddenFeatures(JSON.stringify(features));
950
+ }
951
+
952
+ /**
953
+ * Get features that are hidden on the map.
954
+ */
955
+ public getHiddenFeatures(): Promise<MPFeatureType[]> {
956
+ return MapControlModule.getHiddenFeatures().then((features: string) => JSON.parse(features));
957
+ }
904
958
  }