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

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 (150) hide show
  1. package/LICENSE +10 -10
  2. package/README.md +187 -183
  3. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  4. package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  7. package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  8. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  10. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  11. package/android/README.md +14 -14
  12. package/android/build.gradle +166 -166
  13. package/android/gradle/wrapper/gradle-wrapper.properties +5 -5
  14. package/android/gradle.properties +16 -16
  15. package/android/gradlew +234 -234
  16. package/android/src/main/AndroidManifest.xml +6 -6
  17. package/android/src/main/java/com/reactlibrary/MapboxMapView.java +116 -116
  18. package/android/src/main/java/com/reactlibrary/MapsIndoorsPackage.java +53 -53
  19. package/android/src/main/java/com/reactlibrary/MapsIndoorsViewManager.java +119 -119
  20. package/android/src/main/java/com/reactlibrary/core/DirectionsRendererModule.java +218 -208
  21. package/android/src/main/java/com/reactlibrary/core/DirectionsServiceModule.java +130 -130
  22. package/android/src/main/java/com/reactlibrary/core/MPDisplayRuleModule.java +816 -816
  23. package/android/src/main/java/com/reactlibrary/core/MapControlModule.java +636 -628
  24. package/android/src/main/java/com/reactlibrary/core/MapsIndoorsModule.java +327 -327
  25. package/android/src/main/java/com/reactlibrary/core/RCMapView.java +16 -16
  26. package/android/src/main/java/com/reactlibrary/core/README.md +92 -92
  27. package/android/src/main/java/com/reactlibrary/core/UtilsModule.java +166 -166
  28. package/android/src/main/java/com/reactlibrary/core/models/Bounds.java +19 -19
  29. package/android/src/main/java/com/reactlibrary/core/models/Filter.java +77 -77
  30. package/android/src/main/java/com/reactlibrary/core/models/Location.java +17 -17
  31. package/android/src/main/java/com/reactlibrary/core/models/MPCameraPosition.java +34 -34
  32. package/android/src/main/java/com/reactlibrary/core/models/MPCameraUpdate.java +68 -68
  33. package/android/src/main/java/com/reactlibrary/core/models/MPError.java +38 -38
  34. package/android/src/main/java/com/reactlibrary/core/models/PositionProvider.java +46 -46
  35. package/android/src/main/java/com/reactlibrary/core/models/PositionResult.java +117 -117
  36. package/android/src/main/java/com/reactlibrary/core/models/Query.java +30 -30
  37. package/android/src/main/res/values/google_maps_api_key.xml +3 -3
  38. package/android/src/main/res/values/mapbox_api_key.xml +5 -5
  39. package/index.ts +183 -183
  40. package/ios/MapsIndoors.xcodeproj/project.pbxproj +318 -318
  41. package/ios/MapsIndoors.xcworkspace/contents.xcworkspacedata +7 -7
  42. package/ios/MapsIndoors.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
  43. package/ios/MapsIndoorsViewManager.swift +111 -111
  44. package/ios/MapsIndoorsViewManagerBridge.m +9 -9
  45. package/ios/core/CameraPosition.swift +15 -15
  46. package/ios/core/CameraUpdate.swift +19 -19
  47. package/ios/core/CameraUpdateError.swift +11 -11
  48. package/ios/core/DirectionsRendererBridge.m +61 -57
  49. package/ios/core/DirectionsRendererModule.swift +256 -237
  50. package/ios/core/DirectionsServiceBridge.m +46 -46
  51. package/ios/core/DirectionsServiceModule.swift +149 -149
  52. package/ios/core/MPDisplayRuleBridge.m +410 -410
  53. package/ios/core/MPDisplayRuleModule.swift +845 -845
  54. package/ios/core/MapControlBridge.m +184 -178
  55. package/ios/core/MapControlModule.swift +554 -515
  56. package/ios/core/MapsIndoorsBridge.m +116 -116
  57. package/ios/core/MapsIndoorsData.swift +218 -218
  58. package/ios/core/MapsIndoorsModule.swift +296 -296
  59. package/ios/core/RCMapView.swift +14 -14
  60. package/ios/core/README.md +92 -92
  61. package/ios/core/ReactPositionProvider.swift +25 -25
  62. package/ios/core/UtilsBridge.m +63 -63
  63. package/ios/core/UtilsModule.swift +146 -146
  64. package/ios/core/helpers.swift +57 -57
  65. package/ios/react-native-maps-indoors-Bridging-Header.h +6 -6
  66. package/package.json +53 -53
  67. package/react-native-maps-indoors-mapbox.podspec +30 -30
  68. package/src/core/EventNames.ts +20 -20
  69. package/src/core/MPBounds.ts +154 -154
  70. package/src/core/MPBuilding.ts +333 -333
  71. package/src/core/MPBuildingCollection.ts +56 -56
  72. package/src/core/MPBuildingInfo.ts +62 -62
  73. package/src/core/MPCameraEvent.ts +16 -16
  74. package/src/core/MPCameraEventListener.ts +16 -16
  75. package/src/core/MPCameraPosition.ts +82 -82
  76. package/src/core/MPCameraUpdate.ts +174 -174
  77. package/src/core/MPCameraViewFitMode.ts +20 -20
  78. package/src/core/MPCategory.ts +75 -75
  79. package/src/core/MPCategoryCollection.ts +61 -61
  80. package/src/core/MPCollection.ts +58 -58
  81. package/src/core/MPCollisionHandling.ts +11 -11
  82. package/src/core/MPDataField.ts +68 -68
  83. package/src/core/MPDirectionsRenderer.ts +205 -193
  84. package/src/core/MPDirectionsService.ts +118 -118
  85. package/src/core/MPDisplayRule.ts +1027 -1027
  86. package/src/core/MPEntity.ts +59 -59
  87. package/src/core/MPEntityInfo.ts +27 -27
  88. package/src/core/MPError.ts +122 -122
  89. package/src/core/MPFilter.ts +167 -167
  90. package/src/core/MPFilterBehavior.ts +94 -94
  91. package/src/core/MPFloor.ts +169 -169
  92. package/src/core/MPFloorSelectorInterface.ts +62 -62
  93. package/src/core/MPGeometry.ts +90 -90
  94. package/src/core/MPHighway.ts +14 -14
  95. package/src/core/MPIconSize.ts +38 -38
  96. package/src/core/MPLocation.ts +385 -385
  97. package/src/core/MPLocationPropertyNames.ts +29 -29
  98. package/src/core/MPLocationType.ts +15 -15
  99. package/src/core/MPMapConfig.ts +210 -210
  100. package/src/core/MPMapStyle.ts +56 -56
  101. package/src/core/MPMultiPolygon.ts +217 -217
  102. package/src/core/MPPoint.ts +169 -169
  103. package/src/core/MPPolygon.ts +218 -218
  104. package/src/core/MPPositionProviderInterface.ts +44 -44
  105. package/src/core/MPPositionResultInterface.ts +41 -41
  106. package/src/core/MPPropertyData.ts +214 -214
  107. package/src/core/MPQuery.ts +68 -68
  108. package/src/core/MPRoute.ts +94 -94
  109. package/src/core/MPRouteCoordinate.ts +94 -94
  110. package/src/core/MPRouteLeg.ts +127 -127
  111. package/src/core/MPRouteProperty.ts +82 -82
  112. package/src/core/MPRouteStep.ts +176 -175
  113. package/src/core/MPSelectionBehavior.ts +92 -92
  114. package/src/core/MPSettings3D.ts +106 -106
  115. package/src/core/MPSize.ts +20 -20
  116. package/src/core/MPSolution.ts +179 -179
  117. package/src/core/MPSolutionConfig.ts +126 -126
  118. package/src/core/MPSolutionDisplayRule.ts +13 -13
  119. package/src/core/MPUserRole.ts +59 -59
  120. package/src/core/MPUserRoleCollection.ts +36 -36
  121. package/src/core/MPUtils.ts +156 -156
  122. package/src/core/MPVenue.ts +293 -293
  123. package/src/core/MPVenueCollection.ts +57 -57
  124. package/src/core/MPVenueInfo.ts +61 -61
  125. package/src/core/MapControl.ts +876 -864
  126. package/src/core/MapView.tsx +33 -33
  127. package/src/core/MapsIndoors.ts +530 -530
  128. package/src/core/OnBuildingFoundAtCameraTargetListener.ts +16 -16
  129. package/src/core/OnFloorSelectionChangedListener.ts +16 -16
  130. package/src/core/OnFloorUpdateListener.ts +15 -15
  131. package/src/core/OnLegSelectedListener.ts +16 -16
  132. package/src/core/OnLiveLocationUpdateListener.ts +16 -16
  133. package/src/core/OnLocationSelectedListener.ts +16 -16
  134. package/src/core/OnMapClickListener.ts +19 -19
  135. package/src/core/OnMarkerClickListener.ts +16 -16
  136. package/src/core/OnMarkerInfoWindowClickListener.ts +16 -16
  137. package/src/core/OnPositionUpdateListener.ts +16 -16
  138. package/src/core/OnVenueFoundAtCameraTargetListener.ts +16 -16
  139. package/src/core/README.md +92 -92
  140. package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
  141. package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
  142. package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
  143. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  144. package/android/.gradle/file-system.probe +0 -0
  145. package/android/.idea/compiler.xml +0 -6
  146. package/android/.idea/gradle.xml +0 -19
  147. package/android/.idea/jarRepositories.xml +0 -60
  148. package/android/.idea/misc.xml +0 -10
  149. package/android/.idea/vcs.xml +0 -7
  150. package/android/local.properties +0 -8
@@ -1,864 +1,876 @@
1
- import { EmitterSubscription, NativeEventEmitter, NativeModules } from 'react-native';
2
- import {
3
- MPError, MPFilter, MPFilterBehavior, MPLocation, MPMapConfig,
4
- MPFloorSelectorInterface, MPSelectionBehavior, MPFloor,
5
- MPVenue, MPBuilding, OnMapClickListener, MPPoint, MPCameraEventListener,
6
- OnFloorUpdateListener, OnLocationSelectedListener,
7
- OnVenueFoundAtCameraTargetListener, OnBuildingFoundAtCameraTargetListener,
8
- OnMarkerClickListener, OnMarkerInfoWindowClickListener,
9
- OnLiveLocationUpdateListener, MPCameraEvent, MPMapStyle, MPCameraUpdate, MPCameraPosition, MPEntity,
10
- } from "../../index"
11
- import { EventNames } from './EventNames';
12
-
13
-
14
- const { MapControlModule } = NativeModules;
15
-
16
- /**
17
- * Internal - Documentation will follow.
18
- *
19
- * @export
20
- * @class MapControl
21
- * @typedef {MapControl}
22
- */
23
- export default class MapControl {
24
- /**
25
- * Creates an instance of MapControl
26
- *
27
- * @constructor
28
- * @private
29
- */
30
- private constructor() { }
31
-
32
- /**
33
- * Internal - Documentation will follow.
34
- *
35
- * @private
36
- * @type {?EmitterSubscription}
37
- */
38
- private floorSelector?: EmitterSubscription;
39
- /**
40
- * Internal - Documentation will follow.
41
- *
42
- * @private
43
- * @type {?NativeEventEmitter}
44
- */
45
- private eventEmitter?: NativeEventEmitter;
46
- /**
47
- * Internal - Documentation will follow.
48
- *
49
- * @private
50
- * @type {?EmitterSubscription}
51
- */
52
- private onMapClickSub?: EmitterSubscription;
53
- /**
54
- * Internal - Documentation will follow.
55
- *
56
- * @private
57
- * @type {?EmitterSubscription}
58
- */
59
- private onLocationSelectedSub?: EmitterSubscription;
60
- /**
61
- * Internal - Documentation will follow.
62
- *
63
- * @private
64
- * @type {?EmitterSubscription}
65
- */
66
- private onCurrentVenueChangedSub?: EmitterSubscription;
67
- /**
68
- * Internal - Documentation will follow.
69
- *
70
- * @private
71
- * @type {?EmitterSubscription}
72
- */
73
- private onCurrentBuildingChangedSub?: EmitterSubscription;
74
- /**
75
- * Internal - Documentation will follow.
76
- *
77
- * @private
78
- * @type {?EmitterSubscription}
79
- */
80
- private onMarkerClickSub?: EmitterSubscription;
81
- /**
82
- * Internal - Documentation will follow.
83
- *
84
- * @private
85
- * @type {?EmitterSubscription}
86
- */
87
- private onMarkerInfoWindowClickSub?: EmitterSubscription;
88
- /**
89
- * Internal - Documentation will follow.
90
- *
91
- * @private
92
- * @type {Map<MPCameraEventListener, EmitterSubscription | undefined>}
93
- */
94
- private onCameraEventSubs: Map<MPCameraEventListener, EmitterSubscription | undefined> = new Map;
95
- /**
96
- * Internal - Documentation will follow.
97
- *
98
- * @private
99
- * @type {Map<OnFloorUpdateListener, EmitterSubscription | undefined>}
100
- */
101
- private onFloorUpdateSubs: Map<OnFloorUpdateListener, EmitterSubscription | undefined> = new Map;
102
- /**
103
- * Internal - Documentation will follow.
104
- *
105
- * @private
106
- * @type {Map<string, EmitterSubscription | undefined>}
107
- */
108
- private onLiveUpdateSubs: Map<string, EmitterSubscription | undefined> = new Map;
109
-
110
- /**
111
- * Create a new MapControl instance.
112
- *
113
- * Note that new MapControl instances will only be created when/if the MapsIndoors SDK has initialized successfully.
114
- *
115
- * This method will wait until this condition has been met.
116
- *
117
- * @public
118
- * @static
119
- * @async
120
- * @param {MPMapConfig} config A configuration object that handles setting multiple options for MapControl.
121
- * @param {typeof NativeEventEmitter} nativeEventEmitter An event emitter needed to communicate with the native SDKs.
122
- * @returns {Promise<MapControl>} A ready to use MapControl instace.
123
- */
124
- public static async create(config: MPMapConfig, nativeEventEmitter: typeof NativeEventEmitter): Promise<MapControl> {
125
- return MapControlModule.initMapControl(config).then(() => {
126
- const mapControl = new MapControl();
127
- mapControl.eventEmitter = new nativeEventEmitter(MapControlModule);
128
- if (config.floorSelector !== undefined) {
129
- mapControl.setFloorSelector(config.floorSelector);
130
- }
131
- return Promise.resolve(mapControl);
132
- }).catch((err: Error) => Promise.reject(MPError.parse(err)));
133
- }
134
-
135
- /**
136
- * Internal - Documentation will follow.
137
- *
138
- * @private
139
- * @param {MPFloor} newFloor
140
- */
141
- private onFloorSelectionChanged(newFloor: MPFloor): void {
142
- MapControlModule.onFloorSelectionChanged(JSON.stringify(newFloor));
143
- }
144
-
145
- /**
146
- * Select a venue, optionally move the camera to the given venue.
147
- *
148
- * @public
149
- * @async
150
- * @param {MPVenue} venue
151
- * @param {boolean} moveCamera Whether to move the camera such that it shows the selected venue
152
- * @returns {Promise<void>} When the selection (and possible camera animation) has completed
153
- */
154
- public async selectVenue(venue: MPVenue, moveCamera: boolean): Promise<void> {
155
- return MapControlModule.selectVenue(JSON.stringify(venue), moveCamera).then(() => {});
156
- }
157
-
158
- /**
159
- * Get the currently selected venue, if there is any.
160
- *
161
- * @public
162
- * @async
163
- * @returns {Promise<MPVenue | undefined>} The current venue, if any is selected.
164
- */
165
- public async getCurrentVenue(): Promise<MPVenue | undefined> {
166
- return MapControlModule.getCurrentVenue().then((venue: string) =>
167
- venue ? Promise.resolve(MPVenue.create(JSON.parse(venue as string))) : undefined);
168
- }
169
-
170
- /**
171
- * Get the currently selected building, if there is any.
172
- *
173
- * @public
174
- * @async
175
- * @returns {Promise<MPBuilding | undefined>} The current building, if any is selected.
176
- */
177
- public async getCurrentBuilding(): Promise<MPBuilding | undefined> {
178
- return MapControlModule.getCurrentBuilding().then((building: string) =>
179
- building ? Promise.resolve(MPBuilding.create(JSON.parse(building as string))) : undefined);
180
- }
181
-
182
- /**
183
- * Select a building, optionally move the camera to the given building.
184
- *
185
- * @public
186
- * @async
187
- * @param {MPBuilding} building
188
- * @param {boolean} moveCamera Whether to move the camera such that it shows the selected building
189
- * @returns {Promise<void>} When the selection (and possible camera animation) has completed
190
- */
191
- public async selectBuilding(building: MPBuilding, moveCamera: boolean): Promise<void> {
192
- return MapControlModule.selectBuilding(JSON.stringify(building), moveCamera);
193
- }
194
-
195
- /**
196
- * Selects a location based on a {@link MPLocation} object.
197
- *
198
- * @public
199
- * @async
200
- * @param {MPLocation} location
201
- * @param {MPSelectionBehavior} behavior Optionally apply a {@link MPSelectionBehavior}.
202
- * @returns {Promise<void>}
203
- */
204
- public async selectLocation(location: MPLocation, behavior: MPSelectionBehavior): Promise<void>;
205
- /**
206
- * Selects a location based on a id string object.
207
- *
208
- * @public
209
- * @async
210
- * @param {string} id
211
- * @param {MPSelectionBehavior} behavior Optionally apply a {@link MPSelectionBehavior}.
212
- * @returns {Promise<void>}
213
- */
214
- public async selectLocation(id: string, behavior: MPSelectionBehavior): Promise<void>;
215
- /**
216
- * Selects a location based on a id string or location object.
217
- *
218
- * @public Internal, combination of other overrides.
219
- * @async
220
- * @param {(MPLocation | string)} locationOrId
221
- * @param {MPSelectionBehavior} behavior Optionally apply a {@link MPSelectionBehavior}.
222
- * @returns {Promise<void>}
223
- */
224
- public async selectLocation(locationOrId: MPLocation | string, behavior: MPSelectionBehavior): Promise<void> {
225
- if (locationOrId instanceof MPLocation) {
226
- return Promise.resolve(MapControlModule.selectLocation(JSON.stringify(locationOrId), JSON.stringify(behavior)));
227
- } else {
228
- return Promise.resolve(MapControlModule.selectLocationWithId(locationOrId, JSON.stringify(behavior)));
229
- }
230
- }
231
-
232
- /**
233
- * Invoke this method to restore the map to its default state (POIs shown based on their display rules, etc.).
234
- *
235
- * @public
236
- * @async
237
- * @returns {Promise<void>}
238
- */
239
- public async clearFilter(): Promise<void> {
240
- return Promise.resolve(MapControlModule.clearFilter());
241
- }
242
-
243
- /**
244
- * Use this method to display temporary locations, not points of interests location. Use [clearFilter()] to exit this state.
245
- *
246
- * @public
247
- * @async
248
- * @param {MPLocation[]} locations A list of locations to display.
249
- * @param {MPFilterBehavior} filterBehavior How the map should show the applied filter.
250
- * @returns {Promise<boolean>} True if any locations are available.
251
- */
252
- public async setFilter(locations: MPLocation[], filterBehavior: MPFilterBehavior): Promise<boolean>;
253
- /**
254
- * Use this method to display temporary locations, not points of interests location. Use [clearFilter()] to exit this state.
255
- *
256
- * @public
257
- * @async
258
- * @param {MPFilter} filter The applied filter.
259
- * @param {MPFilterBehavior} filterBehavior How the map should show the applied filter.
260
- * @returns {Promise<boolean>} True if any locations are available.
261
- */
262
- public async setFilter(filter: MPFilter, filterBehavior: MPFilterBehavior): Promise<boolean>;
263
- /**
264
- * Use this method to display temporary locations, not points of interests location. Use [clearFilter()] to exit this state.
265
- *
266
- * @public
267
- * @async
268
- * @param {(MPLocation[] | MPFilter)} locationOrFilter The applied filter.
269
- * @param {MPFilterBehavior} filterBehavior How the map should show the applied filter.
270
- * @returns {Promise<boolean>} True if any locations are available.
271
- */
272
- public async setFilter(locationOrFilter: MPLocation[] | MPFilter, filterBehavior: MPFilterBehavior): Promise<boolean> {
273
- if (Array.isArray(locationOrFilter)) {
274
- const locationIds: string[] = new Array();
275
- locationOrFilter.forEach((location => {
276
- locationIds.push(location.id);
277
- }));
278
- return Promise.resolve(MapControlModule.setFilterWithLocations(JSON.stringify(locationIds), JSON.stringify(filterBehavior)));
279
- } else {
280
- return Promise.resolve(MapControlModule.setFilter(JSON.stringify(locationOrFilter), JSON.stringify(filterBehavior)));
281
- }
282
- }
283
-
284
- /**
285
- * Focus the map on the given {@link MPEntity}.
286
- *
287
- * Examples of classes of type {@link MPEntity} are: {@link MPVenue}, {@link MPBuilding},
288
- * {@link MPBuilding}, {@link MPLocation}.
289
- *
290
- * @public
291
- * @async
292
- * @param {MPEntity} entity The entity to move to.
293
- * @returns {Promise<void>}
294
- */
295
- public async goTo(entity: MPEntity): Promise<void> {
296
- return MapControlModule.goTo(JSON.stringify(entity), entity.type).then(() => {});
297
- }
298
-
299
- /**
300
- * Sets padding on the map.
301
- *
302
- * @public
303
- * @async
304
- * @param {number} start
305
- * @param {number} top
306
- * @param {number} end
307
- * @param {number} bottom
308
- * @returns {Promise<void>}
309
- */
310
- public async setMapPadding(start: number, top: number, end: number, bottom: number): Promise<void> {
311
- await MapControlModule.setMapPadding(start, top, end, bottom);
312
- }
313
-
314
- /**
315
- * Gets the Map View bottom padding.
316
- *
317
- * @public
318
- * @async
319
- * @returns {Promise<number>}
320
- */
321
- public async getMapViewPaddingStart(): Promise<number> {
322
- return MapControlModule.getMapViewPaddingStart();
323
- }
324
-
325
- /**
326
- * Gets the Map View bottom padding.
327
- *
328
- * @public
329
- * @async
330
- * @returns {Promise<number>}
331
- */
332
- public async getMapViewPaddingTop(): Promise<number> {
333
- return MapControlModule.getMapViewPaddingTop();
334
- }
335
-
336
- /**
337
- * Gets the Map View bottom padding.
338
- *
339
- * @public
340
- * @async
341
- * @returns {Promise<number>}
342
- */
343
- public async getMapViewPaddingEnd(): Promise<number> {
344
- return MapControlModule.getMapViewPaddingEnd();
345
- }
346
-
347
- /**
348
- * Gets the Map View bottom padding.
349
- *
350
- * @public
351
- * @async
352
- * @returns {Promise<number>}
353
- */
354
- public async getMapViewPaddingBottom(): Promise<number> {
355
- return MapControlModule.getMapViewPaddingBottom();
356
- }
357
-
358
- /**
359
- * Sets the map style for MapsIndoors tiles.
360
- *
361
- * @public
362
- * @async
363
- * @param {MPMapStyle} style Is a {@link MPMapStyle} object, a list of available {@link MPMapStyle}s can be fetched via {@link MapsIndoors.getMapStyles}.
364
- * @returns {Promise<void>}
365
- */
366
- public async setMapStyle(style: MPMapStyle): Promise<void> {
367
- await MapControlModule.setMapStyle(JSON.stringify(style));
368
- }
369
-
370
- /**
371
- * Gets the current map style of MapsIndoors tiles.
372
- *
373
- * @public
374
- * @async
375
- * @returns {Promise<MPMapStyle>}
376
- */
377
- public async getMapStyle(): Promise<MPMapStyle|undefined> {
378
- let mapStyleString = await MapControlModule.getMapStyle();
379
- return Promise.resolve(mapStyleString ? MPMapStyle.create(JSON.parse(mapStyleString)) : undefined);
380
- }
381
-
382
- /**
383
- * Enables/disables the info window on user-selected locations.
384
- *
385
- * The info window is shown by default when the user selects a location (by tapping on it)
386
- *
387
- * @public
388
- * @async
389
- * @param {boolean} show
390
- * @returns {Promise<void>}
391
- */
392
- public async showInfoWindowOnClickedLocation(show: boolean): Promise<void> {
393
- await MapControlModule.showInfoWindowOnClickedLocation(show);
394
- }
395
-
396
- /**
397
- * Call this to deselect a location previously selected with {@link selectLocation(MPLocation, MPSelectionBehavior)}.
398
- *
399
- * @public
400
- * @async
401
- * @returns {Promise<void>}
402
- */
403
- public async deSelectLocation(): Promise<void> {
404
- await MapControlModule.deSelectLocation();
405
- }
406
-
407
- /**
408
- * Returns the current {@link MPFloor} of the current {@link MPBuilding} in focus.
409
- *
410
- * @public
411
- * @async
412
- * @returns {Promise<MPFloor>}
413
- */
414
- public async getCurrentBuildingFloor(): Promise<MPFloor|undefined> {
415
- let floorString = await MapControlModule.getCurrentBuildingFloor();
416
- return Promise.resolve(floorString ? MPFloor.create(JSON.parse(floorString)) : undefined);
417
- }
418
-
419
- /**
420
- * Returns the current floor index or {@link MPFloor.defaultGroundFloorIndex} if no {@link MPBuilding} is in focus.
421
- *
422
- * @public
423
- * @async
424
- * @returns {Promise<number>}
425
- */
426
- public async getCurrentFloorIndex(): Promise<number> {
427
- return MapControlModule.getCurrentFloorIndex();
428
- }
429
-
430
- /**
431
- * Get the zoom level that MapsIndoors is currently using for displaying icons on the map.
432
- *
433
- * @public
434
- * @async
435
- * @returns {Promise<number>}
436
- */
437
- public async getCurrentMapsIndoorsZoom(): Promise<number> {
438
- return MapControlModule.getCurrentMapsIndoorsZoom();
439
- }
440
-
441
- /**
442
- * Sets the current visible floor to the given floorIndex one.
443
- *
444
- * For floor names/z-index pairs check the value returned by {@link MPBuilding.floors}
445
- *
446
- * @public
447
- * @async
448
- * @param {number} floorIndex
449
- * @returns {Promise<void>}
450
- */
451
- public async selectFloor(floorIndex: number): Promise<void> {
452
- await MapControlModule.selectFloor(floorIndex);
453
- }
454
-
455
- /**
456
- * Returns the visibility state of the currently used {@link MPFloorSelectorInterface}.
457
- *
458
- * @public
459
- * @async
460
- * @returns {Promise<boolean>}
461
- */
462
- public async isFloorSelectorHidden(): Promise<boolean> {
463
- return MapControlModule.isFloorSelectorHidden();
464
- }
465
-
466
- /**
467
- * Shows or hides the {@link MPFloorSelectorInterface}, i.e. hiding the View from {@link MapControl}.
468
- *
469
- * {@link MapControl} will still receive relevant events on floor updates, building change etc.
470
- *
471
- * The Interface will also receive the events, making it possible to show/hide in real time, without refreshing the map.
472
- *
473
- * @public
474
- * @async
475
- * @param {boolean} hide
476
- * @returns {Promise<void>}
477
- */
478
- public async hideFloorSelector(hide: boolean): Promise<void> {
479
- await MapControlModule.hideFloorSelector(hide);
480
- }
481
-
482
- /**
483
- * Replaces the default FloorSelector with a custom one.
484
- *
485
- * @public
486
- * @async
487
- * @param {?MPFloorSelectorInterface} [floorSelector]
488
- * @returns {Promise<void>}
489
- */
490
- public async setFloorSelector(floorSelector?: MPFloorSelectorInterface): Promise<void> {
491
- if (floorSelector) {
492
- floorSelector.setOnFloorSelectionChangedListener(this.onFloorSelectionChanged);
493
- await this.setupFloorSelector(floorSelector);
494
- } else {
495
- await this.teardownFloorSelector();
496
- }
497
- }
498
-
499
- /**
500
- * Sets up the floor selector to be able to receive events from the native SDK.
501
- *
502
- * @private
503
- * @async
504
- * @param {MPFloorSelectorInterface} floorSelector
505
- * @returns {Promise<void>}
506
- */
507
- private async setupFloorSelector(floorSelector: MPFloorSelectorInterface): Promise<void> {
508
- return MapControlModule.setFloorSelector(true, floorSelector.isAutoFloorChangeEnabled()).then(() => {
509
- const sub = this.eventEmitter?.addListener(EventNames.floorSelector, event => {
510
- const fs = floorSelector;
511
- const method: String = event.method;
512
- switch (method) {
513
- case "setList": {
514
- fs.setFloors(event.list ?
515
- JSON.parse(event.list).map((venue: any) => MPFloor.create(venue)) :
516
- undefined);
517
- }
518
- break;
519
- case "show": {
520
- fs.show(event.show, event.animated);
521
- }
522
- break;
523
- case "setSelectedFloor": {
524
- fs.setSelectedFloor(MPFloor.create(JSON.parse(event.floor)));
525
- }
526
- break;
527
- case "setSelectedFloorByFloorIndex": {
528
- fs.setSelectedFloorByFloorIndex(event.floorIndex);
529
- }
530
- break;
531
- case "zoomLevelChanged": {
532
- fs.zoomLevelChanged(event.zoom);
533
- }
534
- break;
535
- case "setUserPositionFloor": {
536
- fs.setUserPositionFloor(event.floor);
537
- }
538
- break;
539
- }
540
- });
541
- this.floorSelector = sub;
542
- return Promise.resolve();
543
- });
544
- }
545
-
546
- /**
547
- * Removes a custom floor selector.
548
- *
549
- * @private
550
- * @async
551
- * @returns {Promise<void>}
552
- */
553
- private async teardownFloorSelector(): Promise<void> {
554
- return MapControlModule.setFloorSelector(false).then(() => {
555
- this.floorSelector?.remove();
556
- this.floorSelector = undefined;
557
- return Promise.resolve();
558
- });
559
- }
560
-
561
-
562
- /**
563
- * Renders the positioning blue dot at the last known user position on the map.
564
- *
565
- * @public
566
- * @async
567
- * @param {boolean} show
568
- * @returns {Promise<void>}
569
- */
570
- public async showUserPosition(show: boolean): Promise<void> {
571
- return MapControlModule.showUserPosition(show).then(() => Promise.resolve());
572
- }
573
-
574
- /**
575
- * Returns the current visibility state of the user location icon (blue dot).
576
- *
577
- * @public
578
- * @async
579
- * @returns {Promise<boolean>}
580
- */
581
- public async isUserPositionShown(): Promise<boolean> {
582
- return MapControlModule.isUserPositionShown();
583
- }
584
-
585
- /**
586
- * Enables live data on a specific domain and uses MapsIndoors standard graphic implementation.
587
- *
588
- * Uses a domainType string, use {@link LiveDataDomainTypes} to get supported strings.
589
- *
590
- * @public
591
- * @async
592
- * @param {string} domainType
593
- * @param {?OnLiveLocationUpdateListener} [listener]
594
- * @returns {Promise<void>}
595
- */
596
- public async enableLiveData(domainType: string, listener?: OnLiveLocationUpdateListener): Promise<void> {
597
- await MapControlModule.enableLiveData(domainType, listener !== undefined);
598
- if (listener) {
599
- this.addLiveDataListener(domainType, listener);
600
- }
601
- }
602
-
603
- /**
604
- * Set up livedata listener to receive events from the native SDK.
605
- *
606
- * @private
607
- * @param {string} domainType
608
- * @param {OnLiveLocationUpdateListener} listener
609
- */
610
- private addLiveDataListener(domainType: string, listener: OnLiveLocationUpdateListener) {
611
- this.onLiveUpdateSubs.get(domainType)?.remove();
612
- const sub = this.eventEmitter?.addListener(EventNames.onLiveLocationUpdate, event => {
613
- const location = MPLocation.create(JSON.parse(event.location));
614
- listener(location);
615
- });
616
- this.onLiveUpdateSubs.set(domainType, sub);
617
- }
618
-
619
- /**
620
- * Disables live data for a specific domainType.
621
- *
622
- * @public
623
- * @async
624
- * @param {string} domainType
625
- * @returns {Promise<void>}
626
- */
627
- public async disableLiveData(domainType: string): Promise<void> {
628
- await MapControlModule.disableLiveData(domainType);
629
- this.removeLiveDataListener(domainType);
630
- }
631
-
632
- /**
633
- * Destroy up livedata listener to receive events from the native SDK.
634
- *
635
- * @private
636
- * @param {string} domainType
637
- */
638
- private removeLiveDataListener(domainType: string) {
639
- this.onLiveUpdateSubs.get(domainType)?.remove();
640
- this.onLiveUpdateSubs.delete(domainType);
641
- }
642
-
643
- /**
644
- * Uses a camera update to animate the camera.
645
- *
646
- * @public
647
- * @async
648
- * @param {MPCameraUpdate} update How to update the camera.
649
- * @param {?number} [duration] how long the animation should take in ms.
650
- * @returns {Promise<void>}
651
- */
652
- public async animateCamera(update: MPCameraUpdate, duration?: number): Promise<void> {
653
- if (duration === undefined) {
654
- duration = -1;
655
- }
656
- await MapControlModule.animateCamera(JSON.stringify(update), duration);
657
- }
658
-
659
- /**
660
- * Uses a camera update to move the camera instantly.
661
- *
662
- * @public
663
- * @async
664
- * @param {MPCameraUpdate} update How to update the camera.
665
- * @returns {Promise<void>}
666
- */
667
- public async moveCamera(update: MPCameraUpdate): Promise<void> {
668
- await MapControlModule.moveCamera(JSON.stringify(update));
669
- }
670
-
671
- /**
672
- * Saves the current position of the camera into a {@link MPCameraPosition}.
673
- *
674
- * @public
675
- * @async
676
- * @returns {Promise<MPCameraPosition>}
677
- */
678
- public async getCurrentCameraPosition(): Promise<MPCameraPosition> {
679
- let positionString = await MapControlModule.getCurrentCameraPosition();
680
- return Promise.resolve(MPCameraPosition.create(JSON.parse(positionString)));
681
- }
682
-
683
- /**
684
- * Set a listener for when the map has been tapped.
685
- *
686
- * @public
687
- * @param {?OnMapClickListener} [listener] Call with undefined to remove the listener.
688
- * @param {?boolean} [consumeEvent] Whether the SDK should also react to this event.
689
- */
690
- public setOnMapClickListener(listener?: OnMapClickListener, consumeEvent?: boolean): void {
691
- MapControlModule.setOnMapClickListener(listener !== undefined, consumeEvent ? true : false);
692
- this.onMapClickSub?.remove();
693
- if (listener !== undefined) {
694
- this.onMapClickSub = this.eventEmitter?.addListener(EventNames.onMapClick, event => {
695
- const point: MPPoint = MPPoint.create(JSON.parse(event.point));
696
- if (event.locations != null) {
697
- const locs: MPLocation[] = JSON.parse(event.locations).map((loc: any) => MPLocation.create(loc));
698
- listener(point, locs);
699
- }else {
700
- listener(point, undefined)
701
- }
702
- });
703
- }
704
- }
705
-
706
- /**
707
- * Set a location selection listener, invoked when a location is selected,
708
- * either by tapping on it, or programmatically with {@link selectLocation}.
709
- *
710
- * @public
711
- * @param {?OnLocationSelectedListener} [listener]
712
- * @param {?boolean} [consumeEvent] Whether the SDK should also react to this event.
713
- */
714
- public setOnLocationSelectedListener(listener?: OnLocationSelectedListener, consumeEvent?: boolean): void {
715
- MapControlModule.setOnLocationSelectedListener(listener !== undefined, consumeEvent !== undefined && consumeEvent);
716
- this.onLocationSelectedSub?.remove();
717
- if (listener !== undefined) {
718
- this.onLocationSelectedSub = this.eventEmitter?.addListener(EventNames.onLocationSelected, event => {
719
- const loc: MPLocation = MPLocation.create(JSON.parse(event.location));
720
- listener(loc);
721
- });
722
- }
723
- }
724
-
725
- /**
726
- * Set a current venue changed event listener, which is invoked when the currently selected venue changes.
727
- *
728
- * @public
729
- * @param {?OnVenueFoundAtCameraTargetListener} [listener]
730
- */
731
- public setOnCurrentVenueChangedListener(listener?: OnVenueFoundAtCameraTargetListener): void {
732
- MapControlModule.setOnCurrentVenueChangedListener(listener !== undefined);
733
- this.onCurrentVenueChangedSub?.remove();
734
- if (listener !== undefined) {
735
- this.onCurrentVenueChangedSub = this.eventEmitter?.addListener(EventNames.onVenueFoundAtCameraTarget, event => {
736
- const venueString = JSON.parse(event.venue);
737
- if (venueString != undefined) {
738
- listener(MPVenue.create(venueString))
739
- } else {
740
- listener();
741
- }
742
- });
743
- }
744
- }
745
-
746
- /**
747
- * Set a current building changed event listener, which is invoked when the currently selected building changes.
748
- *
749
- * @public
750
- * @param {?OnBuildingFoundAtCameraTargetListener} [listener]
751
- */
752
- public setOnCurrentBuildingChangedListener(listener?: OnBuildingFoundAtCameraTargetListener): void {
753
- MapControlModule.setOnCurrentBuildingChangedListener(listener !== undefined);
754
- this.onCurrentBuildingChangedSub?.remove();
755
- if (listener !== undefined) {
756
- this.onCurrentBuildingChangedSub = this.eventEmitter?.addListener(EventNames.onBuildingFoundAtCameraTarget, event => {
757
- const buildingString = JSON.parse(event.building);
758
- if (buildingString != undefined) {
759
- listener(MPBuilding.create(buildingString));
760
- } else {
761
- listener();
762
- }
763
-
764
- });
765
- }
766
- }
767
-
768
- /**
769
- * Set a marker click event listener, invoked when a marker is clicked.
770
- *
771
- * @public
772
- * @param {?OnMarkerClickListener} [listener]
773
- * @param {?boolean} [consumeEvent] Whether the SDK should also react to this event.
774
- */
775
- public setOnMarkerClickListener(listener?: OnMarkerClickListener, consumeEvent?: boolean): void {
776
- MapControlModule.setOnMarkerClickListener(listener !== undefined, consumeEvent !== undefined && consumeEvent);
777
- this.onMarkerClickSub?.remove();
778
- if (listener !== undefined) {
779
- this.onMarkerClickSub = this.eventEmitter?.addListener(EventNames.onMarkerClick, event => {
780
- const locId = event.locationId;
781
- listener(locId);
782
- });
783
- }
784
- }
785
-
786
- /**
787
- * Set a info window click listener, invoked when an info window is clicked.
788
- *
789
- * @public
790
- * @param {?OnMarkerInfoWindowClickListener} [listener]
791
- */
792
- public setOnMarkerInfoWindowClickListener(listener?: OnMarkerInfoWindowClickListener): void {
793
- MapControlModule.setOnMarkerInfoWindowClickListener(listener !== undefined);
794
- this.onMarkerInfoWindowClickSub?.remove();
795
- if (listener !== undefined) {
796
- this.onMarkerInfoWindowClickSub = this.eventEmitter?.addListener(EventNames.onInfoWindowClick, event => {
797
- const locId = event.locationId;
798
- listener(locId);
799
- });
800
- }
801
- }
802
-
803
- /**
804
- * Add a camera event listener, invoked when a camera event occurs (e.g. moved, idle) (see {@link MPCameraEvent}).
805
- *
806
- * @public
807
- * @param {MPCameraEventListener} listener
808
- */
809
- public addOnCameraEventListener(listener: MPCameraEventListener): void {
810
- if (this.onCameraEventSubs.size == 0) {
811
- MapControlModule.setMPCameraEventListener(true);
812
- }
813
- const sub = this.eventEmitter?.addListener(EventNames.cameraEvent, event => {
814
- const cameraEvent: MPCameraEvent = event.event;
815
- listener(cameraEvent);
816
- });
817
- this.onCameraEventSubs.set(listener, sub);
818
- }
819
-
820
- /**
821
- * Remove a camera event listener.
822
- *
823
- * @public
824
- * @param {MPCameraEventListener} listener
825
- */
826
- public removeOnCameraEventListener(listener: MPCameraEventListener): void {
827
- this.onCameraEventSubs.get(listener)?.remove();
828
- this.onCameraEventSubs.delete(listener);
829
- if (this.onCameraEventSubs.size == 0) {
830
- MapControlModule.setMPCameraEventListener(false);
831
- }
832
- }
833
-
834
- /**
835
- * Add a listener object to catch floor changes made by either the user or the positioning service.
836
- *
837
- * @public
838
- * @param {OnFloorUpdateListener} listener
839
- */
840
- public addOnFloorUpdateListener(listener: OnFloorUpdateListener): void {
841
- if (this.onCameraEventSubs.size == 0) {
842
- MapControlModule.setOnFloorUpdateListener(true);
843
- }
844
- const sub = this.eventEmitter?.addListener(EventNames.onFloorUpdate, event => {
845
- const floor = event.floorIndex;
846
- listener(floor);
847
- });
848
- this.onFloorUpdateSubs.set(listener, sub);
849
- }
850
-
851
- /**
852
- * Remove a floor update listener.
853
- *
854
- * @public
855
- * @param {OnFloorUpdateListener} listener
856
- */
857
- public removeOnFloorUpdateListener(listener: OnFloorUpdateListener): void {
858
- this.onFloorUpdateSubs.get(listener)?.remove();
859
- this.onFloorUpdateSubs.delete(listener);
860
- if (this.onCameraEventSubs.size == 0) {
861
- MapControlModule.setOnFloorUpdateListener(false);
862
- }
863
- }
864
- }
1
+ import { EmitterSubscription, NativeEventEmitter, NativeModules } from 'react-native';
2
+ import {
3
+ MPError, MPFilter, MPFilterBehavior, MPLocation, MPMapConfig,
4
+ MPFloorSelectorInterface, MPSelectionBehavior, MPFloor,
5
+ MPVenue, MPBuilding, OnMapClickListener, MPPoint, MPCameraEventListener,
6
+ OnFloorUpdateListener, OnLocationSelectedListener,
7
+ OnVenueFoundAtCameraTargetListener, OnBuildingFoundAtCameraTargetListener,
8
+ OnMarkerClickListener, OnMarkerInfoWindowClickListener,
9
+ OnLiveLocationUpdateListener, MPCameraEvent, MPMapStyle, MPCameraUpdate, MPCameraPosition, MPEntity,
10
+ } from "../../index"
11
+ import { EventNames } from './EventNames';
12
+
13
+
14
+ const { MapControlModule } = NativeModules;
15
+
16
+ /**
17
+ * Internal - Documentation will follow.
18
+ *
19
+ * @export
20
+ * @class MapControl
21
+ * @typedef {MapControl}
22
+ */
23
+ export default class MapControl {
24
+ /**
25
+ * Creates an instance of MapControl
26
+ *
27
+ * @constructor
28
+ * @private
29
+ */
30
+ private constructor() { }
31
+
32
+ /**
33
+ * Internal - Documentation will follow.
34
+ *
35
+ * @private
36
+ * @type {?EmitterSubscription}
37
+ */
38
+ private floorSelector?: EmitterSubscription;
39
+ /**
40
+ * Internal - Documentation will follow.
41
+ *
42
+ * @private
43
+ * @type {?NativeEventEmitter}
44
+ */
45
+ private eventEmitter?: NativeEventEmitter;
46
+ /**
47
+ * Internal - Documentation will follow.
48
+ *
49
+ * @private
50
+ * @type {?EmitterSubscription}
51
+ */
52
+ private onMapClickSub?: EmitterSubscription;
53
+ /**
54
+ * Internal - Documentation will follow.
55
+ *
56
+ * @private
57
+ * @type {?EmitterSubscription}
58
+ */
59
+ private onLocationSelectedSub?: EmitterSubscription;
60
+ /**
61
+ * Internal - Documentation will follow.
62
+ *
63
+ * @private
64
+ * @type {?EmitterSubscription}
65
+ */
66
+ private onCurrentVenueChangedSub?: EmitterSubscription;
67
+ /**
68
+ * Internal - Documentation will follow.
69
+ *
70
+ * @private
71
+ * @type {?EmitterSubscription}
72
+ */
73
+ private onCurrentBuildingChangedSub?: EmitterSubscription;
74
+ /**
75
+ * Internal - Documentation will follow.
76
+ *
77
+ * @private
78
+ * @type {?EmitterSubscription}
79
+ */
80
+ private onMarkerClickSub?: EmitterSubscription;
81
+ /**
82
+ * Internal - Documentation will follow.
83
+ *
84
+ * @private
85
+ * @type {?EmitterSubscription}
86
+ */
87
+ private onMarkerInfoWindowClickSub?: EmitterSubscription;
88
+ /**
89
+ * Internal - Documentation will follow.
90
+ *
91
+ * @private
92
+ * @type {Map<MPCameraEventListener, EmitterSubscription | undefined>}
93
+ */
94
+ private onCameraEventSubs: Map<MPCameraEventListener, EmitterSubscription | undefined> = new Map;
95
+ /**
96
+ * Internal - Documentation will follow.
97
+ *
98
+ * @private
99
+ * @type {Map<OnFloorUpdateListener, EmitterSubscription | undefined>}
100
+ */
101
+ private onFloorUpdateSubs: Map<OnFloorUpdateListener, EmitterSubscription | undefined> = new Map;
102
+ /**
103
+ * Internal - Documentation will follow.
104
+ *
105
+ * @private
106
+ * @type {Map<string, EmitterSubscription | undefined>}
107
+ */
108
+ private onLiveUpdateSubs: Map<string, EmitterSubscription | undefined> = new Map;
109
+
110
+ /**
111
+ * Create a new MapControl instance.
112
+ *
113
+ * Note that new MapControl instances will only be created when/if the MapsIndoors SDK has initialized successfully.
114
+ *
115
+ * This method will wait until this condition has been met.
116
+ *
117
+ * @public
118
+ * @static
119
+ * @async
120
+ * @param {MPMapConfig} config A configuration object that handles setting multiple options for MapControl.
121
+ * @param {typeof NativeEventEmitter} nativeEventEmitter An event emitter needed to communicate with the native SDKs.
122
+ * @returns {Promise<MapControl>} A ready to use MapControl instace.
123
+ */
124
+ public static async create(config: MPMapConfig, nativeEventEmitter: typeof NativeEventEmitter): Promise<MapControl> {
125
+ return MapControlModule.initMapControl(config).then(() => {
126
+ const mapControl = new MapControl();
127
+ mapControl.eventEmitter = new nativeEventEmitter(MapControlModule);
128
+ if (config.floorSelector !== undefined) {
129
+ mapControl.setFloorSelector(config.floorSelector);
130
+ }
131
+ return Promise.resolve(mapControl);
132
+ }).catch((err: Error) => Promise.reject(MPError.parse(err)));
133
+ }
134
+
135
+ /**
136
+ * Internal - Documentation will follow.
137
+ *
138
+ * @private
139
+ * @param {MPFloor} newFloor
140
+ */
141
+ private onFloorSelectionChanged(newFloor: MPFloor): void {
142
+ MapControlModule.onFloorSelectionChanged(JSON.stringify(newFloor));
143
+ }
144
+
145
+ /**
146
+ * Select a venue, optionally move the camera to the given venue.
147
+ *
148
+ * @public
149
+ * @async
150
+ * @param {MPVenue} venue
151
+ * @param {boolean} moveCamera Whether to move the camera such that it shows the selected venue
152
+ * @returns {Promise<void>} When the selection (and possible camera animation) has completed
153
+ */
154
+ public async selectVenue(venue: MPVenue, moveCamera: boolean): Promise<void> {
155
+ return MapControlModule.selectVenue(JSON.stringify(venue), moveCamera).then(() => {});
156
+ }
157
+
158
+ /**
159
+ * Get the currently selected venue, if there is any.
160
+ *
161
+ * @public
162
+ * @async
163
+ * @returns {Promise<MPVenue | undefined>} The current venue, if any is selected.
164
+ */
165
+ public async getCurrentVenue(): Promise<MPVenue | undefined> {
166
+ return MapControlModule.getCurrentVenue().then((venue: string) =>
167
+ venue ? Promise.resolve(MPVenue.create(JSON.parse(venue as string))) : undefined);
168
+ }
169
+
170
+ /**
171
+ * Get the currently selected building, if there is any.
172
+ *
173
+ * @public
174
+ * @async
175
+ * @returns {Promise<MPBuilding | undefined>} The current building, if any is selected.
176
+ */
177
+ public async getCurrentBuilding(): Promise<MPBuilding | undefined> {
178
+ return MapControlModule.getCurrentBuilding().then((building: string) =>
179
+ building ? Promise.resolve(MPBuilding.create(JSON.parse(building as string))) : undefined);
180
+ }
181
+
182
+ /**
183
+ * Select a building, optionally move the camera to the given building.
184
+ *
185
+ * @public
186
+ * @async
187
+ * @param {MPBuilding} building
188
+ * @param {boolean} moveCamera Whether to move the camera such that it shows the selected building
189
+ * @returns {Promise<void>} When the selection (and possible camera animation) has completed
190
+ */
191
+ public async selectBuilding(building: MPBuilding, moveCamera: boolean): Promise<void> {
192
+ return MapControlModule.selectBuilding(JSON.stringify(building), moveCamera);
193
+ }
194
+
195
+ /**
196
+ * Selects a location based on a {@link MPLocation} object.
197
+ *
198
+ * @public
199
+ * @async
200
+ * @param {MPLocation} location
201
+ * @param {MPSelectionBehavior} behavior Optionally apply a {@link MPSelectionBehavior}.
202
+ * @returns {Promise<void>}
203
+ */
204
+ public async selectLocation(location: MPLocation, behavior: MPSelectionBehavior): Promise<void>;
205
+ /**
206
+ * Selects a location based on a id string object.
207
+ *
208
+ * @public
209
+ * @async
210
+ * @param {string} id
211
+ * @param {MPSelectionBehavior} behavior Optionally apply a {@link MPSelectionBehavior}.
212
+ * @returns {Promise<void>}
213
+ */
214
+ public async selectLocation(id: string, behavior: MPSelectionBehavior): Promise<void>;
215
+ /**
216
+ * Selects a location based on a id string or location object.
217
+ *
218
+ * @public Internal, combination of other overrides.
219
+ * @async
220
+ * @param {(MPLocation | string)} locationOrId
221
+ * @param {MPSelectionBehavior} behavior Optionally apply a {@link MPSelectionBehavior}.
222
+ * @returns {Promise<void>}
223
+ */
224
+ public async selectLocation(locationOrId: MPLocation | string, behavior: MPSelectionBehavior): Promise<void> {
225
+ if (locationOrId instanceof MPLocation) {
226
+ return Promise.resolve(MapControlModule.selectLocation(JSON.stringify(locationOrId), JSON.stringify(behavior)));
227
+ } else {
228
+ return Promise.resolve(MapControlModule.selectLocationWithId(locationOrId, JSON.stringify(behavior)));
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Invoke this method to restore the map to its default state (POIs shown based on their display rules, etc.).
234
+ *
235
+ * @public
236
+ * @async
237
+ * @returns {Promise<void>}
238
+ */
239
+ public async clearFilter(): Promise<void> {
240
+ return Promise.resolve(MapControlModule.clearFilter());
241
+ }
242
+
243
+ /**
244
+ * Use this method to display temporary locations, not points of interests location. Use [clearFilter()] to exit this state.
245
+ *
246
+ * @public
247
+ * @async
248
+ * @param {MPLocation[]} locations A list of locations to display.
249
+ * @param {MPFilterBehavior} filterBehavior How the map should show the applied filter.
250
+ * @returns {Promise<boolean>} True if any locations are available.
251
+ */
252
+ public async setFilter(locations: MPLocation[], filterBehavior: MPFilterBehavior): Promise<boolean>;
253
+ /**
254
+ * Use this method to display temporary locations, not points of interests location. Use [clearFilter()] to exit this state.
255
+ *
256
+ * @public
257
+ * @async
258
+ * @param {MPFilter} filter The applied filter.
259
+ * @param {MPFilterBehavior} filterBehavior How the map should show the applied filter.
260
+ * @returns {Promise<boolean>} True if any locations are available.
261
+ */
262
+ public async setFilter(filter: MPFilter, filterBehavior: MPFilterBehavior): Promise<boolean>;
263
+ /**
264
+ * Use this method to display temporary locations, not points of interests location. Use [clearFilter()] to exit this state.
265
+ *
266
+ * @public
267
+ * @async
268
+ * @param {(MPLocation[] | MPFilter)} locationOrFilter The applied filter.
269
+ * @param {MPFilterBehavior} filterBehavior How the map should show the applied filter.
270
+ * @returns {Promise<boolean>} True if any locations are available.
271
+ */
272
+ public async setFilter(locationOrFilter: MPLocation[] | MPFilter, filterBehavior: MPFilterBehavior): Promise<boolean> {
273
+ if (Array.isArray(locationOrFilter)) {
274
+ const locationIds: string[] = new Array();
275
+ locationOrFilter.forEach((location => {
276
+ locationIds.push(location.id);
277
+ }));
278
+ return Promise.resolve(MapControlModule.setFilterWithLocations(JSON.stringify(locationIds), JSON.stringify(filterBehavior)));
279
+ } else {
280
+ return Promise.resolve(MapControlModule.setFilter(JSON.stringify(locationOrFilter), JSON.stringify(filterBehavior)));
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Focus the map on the given {@link MPEntity}.
286
+ *
287
+ * Examples of classes of type {@link MPEntity} are: {@link MPVenue}, {@link MPBuilding},
288
+ * {@link MPBuilding}, {@link MPLocation}.
289
+ *
290
+ * @public
291
+ * @async
292
+ * @param {MPEntity} entity The entity to move to.
293
+ * @returns {Promise<void>}
294
+ */
295
+ public async goTo(entity: MPEntity): Promise<void> {
296
+ return MapControlModule.goTo(JSON.stringify(entity), entity.type).then(() => {});
297
+ }
298
+
299
+ /**
300
+ * Sets padding on the map.
301
+ *
302
+ * @public
303
+ * @async
304
+ * @param {number} start
305
+ * @param {number} top
306
+ * @param {number} end
307
+ * @param {number} bottom
308
+ * @returns {Promise<void>}
309
+ */
310
+ public async setMapPadding(start: number, top: number, end: number, bottom: number): Promise<void> {
311
+ await MapControlModule.setMapPadding(start, top, end, bottom);
312
+ }
313
+
314
+ /**
315
+ * Gets the Map View bottom padding.
316
+ *
317
+ * @public
318
+ * @async
319
+ * @returns {Promise<number>}
320
+ */
321
+ public async getMapViewPaddingStart(): Promise<number> {
322
+ return MapControlModule.getMapViewPaddingStart();
323
+ }
324
+
325
+ /**
326
+ * Gets the Map View bottom padding.
327
+ *
328
+ * @public
329
+ * @async
330
+ * @returns {Promise<number>}
331
+ */
332
+ public async getMapViewPaddingTop(): Promise<number> {
333
+ return MapControlModule.getMapViewPaddingTop();
334
+ }
335
+
336
+ /**
337
+ * Gets the Map View bottom padding.
338
+ *
339
+ * @public
340
+ * @async
341
+ * @returns {Promise<number>}
342
+ */
343
+ public async getMapViewPaddingEnd(): Promise<number> {
344
+ return MapControlModule.getMapViewPaddingEnd();
345
+ }
346
+
347
+ /**
348
+ * Gets the Map View bottom padding.
349
+ *
350
+ * @public
351
+ * @async
352
+ * @returns {Promise<number>}
353
+ */
354
+ public async getMapViewPaddingBottom(): Promise<number> {
355
+ return MapControlModule.getMapViewPaddingBottom();
356
+ }
357
+
358
+ /**
359
+ * Sets the map style for MapsIndoors tiles.
360
+ *
361
+ * @public
362
+ * @async
363
+ * @param {MPMapStyle} style Is a {@link MPMapStyle} object, a list of available {@link MPMapStyle}s can be fetched via {@link MapsIndoors.getMapStyles}.
364
+ * @returns {Promise<void>}
365
+ */
366
+ public async setMapStyle(style: MPMapStyle): Promise<void> {
367
+ await MapControlModule.setMapStyle(JSON.stringify(style));
368
+ }
369
+
370
+ /**
371
+ * Gets the current map style of MapsIndoors tiles.
372
+ *
373
+ * @public
374
+ * @async
375
+ * @returns {Promise<MPMapStyle>}
376
+ */
377
+ public async getMapStyle(): Promise<MPMapStyle|undefined> {
378
+ let mapStyleString = await MapControlModule.getMapStyle();
379
+ return Promise.resolve(mapStyleString ? MPMapStyle.create(JSON.parse(mapStyleString)) : undefined);
380
+ }
381
+
382
+ /**
383
+ * Enables/disables the info window on user-selected locations.
384
+ *
385
+ * The info window is shown by default when the user selects a location (by tapping on it)
386
+ *
387
+ * @public
388
+ * @async
389
+ * @param {boolean} show
390
+ * @returns {Promise<void>}
391
+ */
392
+ public async showInfoWindowOnClickedLocation(show: boolean): Promise<void> {
393
+ await MapControlModule.showInfoWindowOnClickedLocation(show);
394
+ }
395
+
396
+ /**
397
+ * Call this to deselect a location previously selected with {@link selectLocation(MPLocation, MPSelectionBehavior)}.
398
+ *
399
+ * @public
400
+ * @async
401
+ * @returns {Promise<void>}
402
+ */
403
+ public async deSelectLocation(): Promise<void> {
404
+ await MapControlModule.deSelectLocation();
405
+ }
406
+
407
+ /**
408
+ * Returns the current {@link MPFloor} of the current {@link MPBuilding} in focus.
409
+ *
410
+ * @public
411
+ * @async
412
+ * @returns {Promise<MPFloor>}
413
+ */
414
+ public async getCurrentBuildingFloor(): Promise<MPFloor|undefined> {
415
+ let floorString = await MapControlModule.getCurrentBuildingFloor();
416
+ return Promise.resolve(floorString ? MPFloor.create(JSON.parse(floorString)) : undefined);
417
+ }
418
+
419
+ /**
420
+ * Returns the current floor index or {@link MPFloor.defaultGroundFloorIndex} if no {@link MPBuilding} is in focus.
421
+ *
422
+ * @public
423
+ * @async
424
+ * @returns {Promise<number>}
425
+ */
426
+ public async getCurrentFloorIndex(): Promise<number> {
427
+ return MapControlModule.getCurrentFloorIndex();
428
+ }
429
+
430
+ /**
431
+ * Get the zoom level that MapsIndoors is currently using for displaying icons on the map.
432
+ *
433
+ * @public
434
+ * @async
435
+ * @returns {Promise<number>}
436
+ */
437
+ public async getCurrentMapsIndoorsZoom(): Promise<number> {
438
+ return MapControlModule.getCurrentMapsIndoorsZoom();
439
+ }
440
+
441
+ /**
442
+ * Sets the current visible floor to the given floorIndex one.
443
+ *
444
+ * For floor names/z-index pairs check the value returned by {@link MPBuilding.floors}
445
+ *
446
+ * @public
447
+ * @async
448
+ * @param {number} floorIndex
449
+ * @returns {Promise<void>}
450
+ */
451
+ public async selectFloor(floorIndex: number): Promise<void> {
452
+ await MapControlModule.selectFloor(floorIndex);
453
+ }
454
+
455
+ /**
456
+ * Returns the visibility state of the currently used {@link MPFloorSelectorInterface}.
457
+ *
458
+ * @public
459
+ * @async
460
+ * @returns {Promise<boolean>}
461
+ */
462
+ public async isFloorSelectorHidden(): Promise<boolean> {
463
+ return MapControlModule.isFloorSelectorHidden();
464
+ }
465
+
466
+ /**
467
+ * Shows or hides the {@link MPFloorSelectorInterface}, i.e. hiding the View from {@link MapControl}.
468
+ *
469
+ * {@link MapControl} will still receive relevant events on floor updates, building change etc.
470
+ *
471
+ * The Interface will also receive the events, making it possible to show/hide in real time, without refreshing the map.
472
+ *
473
+ * @public
474
+ * @async
475
+ * @param {boolean} hide
476
+ * @returns {Promise<void>}
477
+ */
478
+ public async hideFloorSelector(hide: boolean): Promise<void> {
479
+ await MapControlModule.hideFloorSelector(hide);
480
+ }
481
+
482
+ /**
483
+ * Replaces the default FloorSelector with a custom one.
484
+ *
485
+ * @public
486
+ * @async
487
+ * @param {?MPFloorSelectorInterface} [floorSelector]
488
+ * @returns {Promise<void>}
489
+ */
490
+ public async setFloorSelector(floorSelector?: MPFloorSelectorInterface): Promise<void> {
491
+ if (floorSelector) {
492
+ floorSelector.setOnFloorSelectionChangedListener(this.onFloorSelectionChanged);
493
+ await this.setupFloorSelector(floorSelector);
494
+ } else {
495
+ await this.teardownFloorSelector();
496
+ }
497
+ }
498
+
499
+ /**
500
+ * Sets up the floor selector to be able to receive events from the native SDK.
501
+ *
502
+ * @private
503
+ * @async
504
+ * @param {MPFloorSelectorInterface} floorSelector
505
+ * @returns {Promise<void>}
506
+ */
507
+ private async setupFloorSelector(floorSelector: MPFloorSelectorInterface): Promise<void> {
508
+ return MapControlModule.setFloorSelector(true, floorSelector.isAutoFloorChangeEnabled()).then(() => {
509
+ const sub = this.eventEmitter?.addListener(EventNames.floorSelector, event => {
510
+ const fs = floorSelector;
511
+ const method: String = event.method;
512
+ switch (method) {
513
+ case "setList": {
514
+ fs.setFloors(event.list ?
515
+ JSON.parse(event.list).map((venue: any) => MPFloor.create(venue)) :
516
+ undefined);
517
+ }
518
+ break;
519
+ case "show": {
520
+ fs.show(event.show, event.animated);
521
+ }
522
+ break;
523
+ case "setSelectedFloor": {
524
+ fs.setSelectedFloor(MPFloor.create(JSON.parse(event.floor)));
525
+ }
526
+ break;
527
+ case "setSelectedFloorByFloorIndex": {
528
+ fs.setSelectedFloorByFloorIndex(event.floorIndex);
529
+ }
530
+ break;
531
+ case "zoomLevelChanged": {
532
+ fs.zoomLevelChanged(event.zoom);
533
+ }
534
+ break;
535
+ case "setUserPositionFloor": {
536
+ fs.setUserPositionFloor(event.floor);
537
+ }
538
+ break;
539
+ }
540
+ });
541
+ this.floorSelector = sub;
542
+ return Promise.resolve();
543
+ });
544
+ }
545
+
546
+ /**
547
+ * Removes a custom floor selector.
548
+ *
549
+ * @private
550
+ * @async
551
+ * @returns {Promise<void>}
552
+ */
553
+ private async teardownFloorSelector(): Promise<void> {
554
+ return MapControlModule.setFloorSelector(false).then(() => {
555
+ this.floorSelector?.remove();
556
+ this.floorSelector = undefined;
557
+ return Promise.resolve();
558
+ });
559
+ }
560
+
561
+
562
+ /**
563
+ * Renders the positioning blue dot at the last known user position on the map.
564
+ *
565
+ * @public
566
+ * @async
567
+ * @param {boolean} show
568
+ * @returns {Promise<void>}
569
+ */
570
+ public async showUserPosition(show: boolean): Promise<void> {
571
+ return MapControlModule.showUserPosition(show).then(() => Promise.resolve());
572
+ }
573
+
574
+ /**
575
+ * Returns the current visibility state of the user location icon (blue dot).
576
+ *
577
+ * @public
578
+ * @async
579
+ * @returns {Promise<boolean>}
580
+ */
581
+ public async isUserPositionShown(): Promise<boolean> {
582
+ return MapControlModule.isUserPositionShown();
583
+ }
584
+
585
+ /**
586
+ * Enables live data on a specific domain and uses MapsIndoors standard graphic implementation.
587
+ *
588
+ * Uses a domainType string, use {@link LiveDataDomainTypes} to get supported strings.
589
+ *
590
+ * @public
591
+ * @async
592
+ * @param {string} domainType
593
+ * @param {?OnLiveLocationUpdateListener} [listener]
594
+ * @returns {Promise<void>}
595
+ */
596
+ public async enableLiveData(domainType: string, listener?: OnLiveLocationUpdateListener): Promise<void> {
597
+ await MapControlModule.enableLiveData(domainType, listener !== undefined);
598
+ if (listener) {
599
+ this.addLiveDataListener(domainType, listener);
600
+ }
601
+ }
602
+
603
+ /**
604
+ * Set up livedata listener to receive events from the native SDK.
605
+ *
606
+ * @private
607
+ * @param {string} domainType
608
+ * @param {OnLiveLocationUpdateListener} listener
609
+ */
610
+ private addLiveDataListener(domainType: string, listener: OnLiveLocationUpdateListener) {
611
+ this.onLiveUpdateSubs.get(domainType)?.remove();
612
+ const sub = this.eventEmitter?.addListener(EventNames.onLiveLocationUpdate, event => {
613
+ const location = MPLocation.create(JSON.parse(event.location));
614
+ listener(location);
615
+ });
616
+ this.onLiveUpdateSubs.set(domainType, sub);
617
+ }
618
+
619
+ /**
620
+ * Disables live data for a specific domainType.
621
+ *
622
+ * @public
623
+ * @async
624
+ * @param {string} domainType
625
+ * @returns {Promise<void>}
626
+ */
627
+ public async disableLiveData(domainType: string): Promise<void> {
628
+ await MapControlModule.disableLiveData(domainType);
629
+ this.removeLiveDataListener(domainType);
630
+ }
631
+
632
+ /**
633
+ * Destroy up livedata listener to receive events from the native SDK.
634
+ *
635
+ * @private
636
+ * @param {string} domainType
637
+ */
638
+ private removeLiveDataListener(domainType: string) {
639
+ this.onLiveUpdateSubs.get(domainType)?.remove();
640
+ this.onLiveUpdateSubs.delete(domainType);
641
+ }
642
+
643
+ /**
644
+ * Uses a camera update to animate the camera.
645
+ *
646
+ * @public
647
+ * @async
648
+ * @param {MPCameraUpdate} update How to update the camera.
649
+ * @param {?number} [duration] how long the animation should take in ms.
650
+ * @returns {Promise<void>}
651
+ */
652
+ public async animateCamera(update: MPCameraUpdate, duration?: number): Promise<void> {
653
+ if (duration === undefined) {
654
+ duration = -1;
655
+ }
656
+ await MapControlModule.animateCamera(JSON.stringify(update), duration);
657
+ }
658
+
659
+ /**
660
+ * Uses a camera update to move the camera instantly.
661
+ *
662
+ * @public
663
+ * @async
664
+ * @param {MPCameraUpdate} update How to update the camera.
665
+ * @returns {Promise<void>}
666
+ */
667
+ public async moveCamera(update: MPCameraUpdate): Promise<void> {
668
+ await MapControlModule.moveCamera(JSON.stringify(update));
669
+ }
670
+
671
+ /**
672
+ * Saves the current position of the camera into a {@link MPCameraPosition}.
673
+ *
674
+ * @public
675
+ * @async
676
+ * @returns {Promise<MPCameraPosition>}
677
+ */
678
+ public async getCurrentCameraPosition(): Promise<MPCameraPosition> {
679
+ let positionString = await MapControlModule.getCurrentCameraPosition();
680
+ return Promise.resolve(MPCameraPosition.create(JSON.parse(positionString)));
681
+ }
682
+
683
+ /**
684
+ * Set a listener for when the map has been tapped.
685
+ *
686
+ * @public
687
+ * @param {?OnMapClickListener} [listener] Call with undefined to remove the listener.
688
+ * @param {?boolean} [consumeEvent] Whether the SDK should also react to this event.
689
+ */
690
+ public setOnMapClickListener(listener?: OnMapClickListener, consumeEvent?: boolean): void {
691
+ MapControlModule.setOnMapClickListener(listener !== undefined, consumeEvent ? true : false);
692
+ this.onMapClickSub?.remove();
693
+ if (listener !== undefined) {
694
+ this.onMapClickSub = this.eventEmitter?.addListener(EventNames.onMapClick, event => {
695
+ const point: MPPoint = MPPoint.create(JSON.parse(event.point));
696
+ if (event.locations != null) {
697
+ const locs: MPLocation[] = JSON.parse(event.locations).map((loc: any) => MPLocation.create(loc));
698
+ listener(point, locs);
699
+ }else {
700
+ listener(point, undefined)
701
+ }
702
+ });
703
+ }
704
+ }
705
+
706
+ /**
707
+ * Set a location selection listener, invoked when a location is selected,
708
+ * either by tapping on it, or programmatically with {@link selectLocation}.
709
+ *
710
+ * @public
711
+ * @param {?OnLocationSelectedListener} [listener]
712
+ * @param {?boolean} [consumeEvent] Whether the SDK should also react to this event.
713
+ */
714
+ public setOnLocationSelectedListener(listener?: OnLocationSelectedListener, consumeEvent?: boolean): void {
715
+ MapControlModule.setOnLocationSelectedListener(listener !== undefined, consumeEvent !== undefined && consumeEvent);
716
+ this.onLocationSelectedSub?.remove();
717
+ if (listener !== undefined) {
718
+ this.onLocationSelectedSub = this.eventEmitter?.addListener(EventNames.onLocationSelected, event => {
719
+ const loc: MPLocation = MPLocation.create(JSON.parse(event.location));
720
+ listener(loc);
721
+ });
722
+ }
723
+ }
724
+
725
+ /**
726
+ * Set a current venue changed event listener, which is invoked when the currently selected venue changes.
727
+ *
728
+ * @public
729
+ * @param {?OnVenueFoundAtCameraTargetListener} [listener]
730
+ */
731
+ public setOnCurrentVenueChangedListener(listener?: OnVenueFoundAtCameraTargetListener): void {
732
+ MapControlModule.setOnCurrentVenueChangedListener(listener !== undefined);
733
+ this.onCurrentVenueChangedSub?.remove();
734
+ if (listener !== undefined) {
735
+ this.onCurrentVenueChangedSub = this.eventEmitter?.addListener(EventNames.onVenueFoundAtCameraTarget, event => {
736
+ const venueString = JSON.parse(event.venue);
737
+ if (venueString != undefined) {
738
+ listener(MPVenue.create(venueString))
739
+ } else {
740
+ listener();
741
+ }
742
+ });
743
+ }
744
+ }
745
+
746
+ /**
747
+ * Set a current building changed event listener, which is invoked when the currently selected building changes.
748
+ *
749
+ * @public
750
+ * @param {?OnBuildingFoundAtCameraTargetListener} [listener]
751
+ */
752
+ public setOnCurrentBuildingChangedListener(listener?: OnBuildingFoundAtCameraTargetListener): void {
753
+ MapControlModule.setOnCurrentBuildingChangedListener(listener !== undefined);
754
+ this.onCurrentBuildingChangedSub?.remove();
755
+ if (listener !== undefined) {
756
+ this.onCurrentBuildingChangedSub = this.eventEmitter?.addListener(EventNames.onBuildingFoundAtCameraTarget, event => {
757
+ const buildingString = JSON.parse(event.building);
758
+ if (buildingString != undefined) {
759
+ listener(MPBuilding.create(buildingString));
760
+ } else {
761
+ listener();
762
+ }
763
+
764
+ });
765
+ }
766
+ }
767
+
768
+ /**
769
+ * Set a marker click event listener, invoked when a marker is clicked.
770
+ *
771
+ * @public
772
+ * @param {?OnMarkerClickListener} [listener]
773
+ * @param {?boolean} [consumeEvent] Whether the SDK should also react to this event.
774
+ */
775
+ public setOnMarkerClickListener(listener?: OnMarkerClickListener, consumeEvent?: boolean): void {
776
+ MapControlModule.setOnMarkerClickListener(listener !== undefined, consumeEvent !== undefined && consumeEvent);
777
+ this.onMarkerClickSub?.remove();
778
+ if (listener !== undefined) {
779
+ this.onMarkerClickSub = this.eventEmitter?.addListener(EventNames.onMarkerClick, event => {
780
+ const locId = event.locationId;
781
+ listener(locId);
782
+ });
783
+ }
784
+ }
785
+
786
+ /**
787
+ * Set a info window click listener, invoked when an info window is clicked.
788
+ *
789
+ * @public
790
+ * @param {?OnMarkerInfoWindowClickListener} [listener]
791
+ */
792
+ public setOnMarkerInfoWindowClickListener(listener?: OnMarkerInfoWindowClickListener): void {
793
+ MapControlModule.setOnMarkerInfoWindowClickListener(listener !== undefined);
794
+ this.onMarkerInfoWindowClickSub?.remove();
795
+ if (listener !== undefined) {
796
+ this.onMarkerInfoWindowClickSub = this.eventEmitter?.addListener(EventNames.onInfoWindowClick, event => {
797
+ const locId = event.locationId;
798
+ listener(locId);
799
+ });
800
+ }
801
+ }
802
+
803
+ /**
804
+ * Add a camera event listener, invoked when a camera event occurs (e.g. moved, idle) (see {@link MPCameraEvent}).
805
+ *
806
+ * @public
807
+ * @param {MPCameraEventListener} listener
808
+ */
809
+ public addOnCameraEventListener(listener: MPCameraEventListener): void {
810
+ if (this.onCameraEventSubs.size == 0) {
811
+ MapControlModule.setMPCameraEventListener(true);
812
+ }
813
+ const sub = this.eventEmitter?.addListener(EventNames.cameraEvent, event => {
814
+ const cameraEvent: MPCameraEvent = event.event;
815
+ listener(cameraEvent);
816
+ });
817
+ this.onCameraEventSubs.set(listener, sub);
818
+ }
819
+
820
+ /**
821
+ * Remove a camera event listener.
822
+ *
823
+ * @public
824
+ * @param {MPCameraEventListener} listener
825
+ */
826
+ public removeOnCameraEventListener(listener: MPCameraEventListener): void {
827
+ this.onCameraEventSubs.get(listener)?.remove();
828
+ this.onCameraEventSubs.delete(listener);
829
+ if (this.onCameraEventSubs.size == 0) {
830
+ MapControlModule.setMPCameraEventListener(false);
831
+ }
832
+ }
833
+
834
+ /**
835
+ * Add a listener object to catch floor changes made by either the user or the positioning service.
836
+ *
837
+ * @public
838
+ * @param {OnFloorUpdateListener} listener
839
+ */
840
+ public addOnFloorUpdateListener(listener: OnFloorUpdateListener): void {
841
+ if (this.onCameraEventSubs.size == 0) {
842
+ MapControlModule.setOnFloorUpdateListener(true);
843
+ }
844
+ const sub = this.eventEmitter?.addListener(EventNames.onFloorUpdate, event => {
845
+ const floor = event.floorIndex;
846
+ listener(floor);
847
+ });
848
+ this.onFloorUpdateSubs.set(listener, sub);
849
+ }
850
+
851
+ /**
852
+ * Remove a floor update listener.
853
+ *
854
+ * @public
855
+ * @param {OnFloorUpdateListener} listener
856
+ */
857
+ public removeOnFloorUpdateListener(listener: OnFloorUpdateListener): void {
858
+ this.onFloorUpdateSubs.get(listener)?.remove();
859
+ this.onFloorUpdateSubs.delete(listener);
860
+ if (this.onCameraEventSubs.size == 0) {
861
+ MapControlModule.setOnFloorUpdateListener(false);
862
+ }
863
+ }
864
+
865
+ /**
866
+ * Set options for location labels
867
+ *
868
+ * @public
869
+ * @param textSize
870
+ * @param color
871
+ * @param showHalo
872
+ */
873
+ public setLabelOptions(textSize: number, color: String, showHalo: boolean): Promise<void> {
874
+ return MapControlModule.setLabelOptions(textSize, color, showHalo).then(() => Promise.resolve());
875
+ }
876
+ }