@mapsindoors/react-native-maps-indoors-mapbox 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsViewManager.java +6 -2
- package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +21 -5
- package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +27 -0
- package/ios/MapsIndoorsViewManager.swift +3 -2
- package/ios/core/MapControlBridge.m +1 -0
- package/ios/core/MapControlModule.swift +8 -2
- package/ios/core/MapsIndoorsBridge.m +4 -0
- package/ios/core/MapsIndoorsModule.swift +35 -0
- package/package.json +1 -1
- package/react-native-maps-indoors-mapbox.podspec +2 -2
- package/src/core/MapControl.ts +1 -1
- package/src/core/MapsIndoors.ts +23 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Documentation
|
|
4
4
|
|
|
5
|
-
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.
|
|
5
|
+
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.4.0/index.html) to get an overview of what the MapsIndoors SDK offers.
|
|
6
6
|
|
|
7
7
|
## Getting started
|
|
8
8
|
|
package/android/build.gradle
CHANGED
|
@@ -93,7 +93,7 @@ dependencies {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
implementation 'com.mapbox.maps:android:11.7.0'
|
|
96
|
-
implementation 'com.mapspeople.mapsindoors:mapbox-v11:4.
|
|
96
|
+
implementation 'com.mapspeople.mapsindoors:mapbox-v11:4.11.0'
|
|
97
97
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
98
98
|
implementation 'androidx.core:core-ktx:1.3.2'
|
|
99
99
|
implementation 'com.github.bumptech.glide:glide:4.16.0'
|
|
@@ -18,6 +18,8 @@ import com.google.gson.Gson;
|
|
|
18
18
|
import com.mapbox.geojson.Point;
|
|
19
19
|
import com.mapbox.maps.CameraOptions;
|
|
20
20
|
import com.mapbox.maps.CameraState;
|
|
21
|
+
import com.mapbox.maps.GlyphsRasterizationMode;
|
|
22
|
+
import com.mapbox.maps.GlyphsRasterizationOptions;
|
|
21
23
|
import com.mapbox.maps.MapInitOptions;
|
|
22
24
|
import com.mapbox.maps.MapView;
|
|
23
25
|
import com.mapbox.maps.plugin.compass.CompassUtils;
|
|
@@ -54,7 +56,9 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
54
56
|
@NonNull
|
|
55
57
|
@Override
|
|
56
58
|
protected MapView createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
57
|
-
MapInitOptions options = new MapInitOptions(reactContext, MapInitOptions.Companion.getDefaultMapOptions(reactContext)
|
|
59
|
+
MapInitOptions options = new MapInitOptions(reactContext, MapInitOptions.Companion.getDefaultMapOptions(reactContext).toBuilder()
|
|
60
|
+
.glyphsRasterizationOptions(new GlyphsRasterizationOptions.Builder().rasterizationMode(GlyphsRasterizationMode.ALL_GLYPHS_RASTERIZED_LOCALLY).build()).build(),
|
|
61
|
+
MapInitOptions.Companion.getDefaultPluginList(), new CameraOptions.Builder().pitch(0.0).build());
|
|
58
62
|
view = new MapView(reactContext, options);
|
|
59
63
|
return view;
|
|
60
64
|
}
|
|
@@ -89,7 +93,7 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
89
93
|
if (!args.isNull(2)) {
|
|
90
94
|
if (args.getBoolean(2)) {
|
|
91
95
|
CompassUtils.getCompass(view).setEnabled(true);
|
|
92
|
-
}else {
|
|
96
|
+
}else {
|
|
93
97
|
CompassUtils.getCompass(view).setEnabled(false);
|
|
94
98
|
}
|
|
95
99
|
}
|
|
@@ -172,26 +172,42 @@ public class MapControlModule extends ReactContextBaseJavaModule implements MPCa
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
@ReactMethod
|
|
175
|
-
public void goTo(String entityString, String entityType, final Promise promise) {
|
|
175
|
+
public void goTo(String entityString, String entityType, Double maxZoom, final Promise promise) {
|
|
176
176
|
switch (entityType) {
|
|
177
177
|
case "MPLocation": {
|
|
178
178
|
MPLocation location = gson.fromJson(entityString, Location.class).toMPLocation();
|
|
179
|
-
|
|
179
|
+
if (maxZoom != -999) {
|
|
180
|
+
mCtx.runOnUiQueueThread(() -> mMapControl.goTo(location, maxZoom));
|
|
181
|
+
}else {
|
|
182
|
+
mCtx.runOnUiQueueThread(() -> mMapControl.goTo(location));
|
|
183
|
+
}
|
|
180
184
|
break;
|
|
181
185
|
}
|
|
182
186
|
case "MPFloor": {
|
|
183
187
|
MPFloor floor = gson.fromJson(entityString, MPFloor.class);
|
|
184
|
-
|
|
188
|
+
if (maxZoom != -999) {
|
|
189
|
+
mCtx.runOnUiQueueThread(() -> mMapControl.goTo(floor, maxZoom));
|
|
190
|
+
}else {
|
|
191
|
+
mCtx.runOnUiQueueThread(() -> mMapControl.goTo(floor));
|
|
192
|
+
}
|
|
185
193
|
break;
|
|
186
194
|
}
|
|
187
195
|
case "MPBuilding": {
|
|
188
196
|
MPBuilding building = gson.fromJson(entityString, MPBuilding.class);
|
|
189
|
-
|
|
197
|
+
if (maxZoom != -999) {
|
|
198
|
+
mCtx.runOnUiQueueThread(() -> mMapControl.goTo(building, maxZoom));
|
|
199
|
+
}else {
|
|
200
|
+
mCtx.runOnUiQueueThread(() -> mMapControl.goTo(building));
|
|
201
|
+
}
|
|
190
202
|
break;
|
|
191
203
|
}
|
|
192
204
|
case "MPVenue": {
|
|
193
205
|
MPVenue venue = gson.fromJson(entityString, MPVenue.class);
|
|
194
|
-
|
|
206
|
+
if (maxZoom != -999) {
|
|
207
|
+
mCtx.runOnUiQueueThread(() -> mMapControl.goTo(venue, maxZoom));
|
|
208
|
+
}else {
|
|
209
|
+
mCtx.runOnUiQueueThread(() -> mMapControl.goTo(venue));
|
|
210
|
+
}
|
|
195
211
|
break;
|
|
196
212
|
}
|
|
197
213
|
}
|
|
@@ -12,6 +12,10 @@ import com.mapsindoors.core.MPBuilding;
|
|
|
12
12
|
import com.mapsindoors.core.MPBuildingCollection;
|
|
13
13
|
import com.mapsindoors.core.MPCategory;
|
|
14
14
|
import com.mapsindoors.core.MPCategoryCollection;
|
|
15
|
+
import com.mapsindoors.core.MPDataSetCache;
|
|
16
|
+
import com.mapsindoors.core.MPDataSetCacheManager;
|
|
17
|
+
import com.mapsindoors.core.MPDataSetCacheScope;
|
|
18
|
+
import com.mapsindoors.core.MPDataSetManagerStatus;
|
|
15
19
|
import com.mapsindoors.core.MPDisplayRule;
|
|
16
20
|
import com.mapsindoors.core.MPFilter;
|
|
17
21
|
import com.mapsindoors.core.MPLocation;
|
|
@@ -32,6 +36,7 @@ import com.mapsindoorsrn.core.models.PositionResult;
|
|
|
32
36
|
import com.mapsindoorsrn.core.models.Query;
|
|
33
37
|
|
|
34
38
|
import java.util.ArrayList;
|
|
39
|
+
import java.util.Collections;
|
|
35
40
|
import java.util.List;
|
|
36
41
|
|
|
37
42
|
public class MapsIndoorsModule extends ReactContextBaseJavaModule {
|
|
@@ -380,4 +385,26 @@ public class MapsIndoorsModule extends ReactContextBaseJavaModule {
|
|
|
380
385
|
promise.resolve(null);
|
|
381
386
|
}
|
|
382
387
|
}
|
|
388
|
+
|
|
389
|
+
@ReactMethod
|
|
390
|
+
public void cacheData(String apiKey, Promise promise) {
|
|
391
|
+
if (!MPDataSetCacheManager.isInitialized()) {
|
|
392
|
+
MPDataSetCacheManager.initialize(reactContext);
|
|
393
|
+
}
|
|
394
|
+
MPDataSetCache cache = MPDataSetCacheManager.getInstance().getDataSetByID(apiKey);
|
|
395
|
+
if (cache == null) {
|
|
396
|
+
cache = MPDataSetCacheManager.getInstance().addDataSetWithCachingScope(apiKey, MPDataSetCacheScope.FULL);
|
|
397
|
+
}else {
|
|
398
|
+
cache.setScope(MPDataSetCacheScope.FULL);
|
|
399
|
+
}
|
|
400
|
+
MPDataSetCache finalCache = cache;
|
|
401
|
+
MPDataSetCacheManager.getInstance().addMPDataSetCacheSyncListener(((mpDataSetCache, i) -> {
|
|
402
|
+
if (i == MPDataSetManagerStatus.SYNC_FINISHED && finalCache.getSolutionId().equals(mpDataSetCache.getSolutionId())) {
|
|
403
|
+
promise.resolve(true);
|
|
404
|
+
} else if (i == MPDataSetManagerStatus.SYNC_FAILED && finalCache.getSolutionId().equals(mpDataSetCache.getSolutionId())) {
|
|
405
|
+
promise.resolve(false);
|
|
406
|
+
}
|
|
407
|
+
}));
|
|
408
|
+
MPDataSetCacheManager.getInstance().synchronizeDataSets(Collections.singletonList(cache));
|
|
409
|
+
}
|
|
383
410
|
}
|
|
@@ -21,8 +21,9 @@ class MapsIndoorsViewManager : RCTViewManager {
|
|
|
21
21
|
pitch: 0
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
let options = MapInitOptions(
|
|
25
|
-
|
|
24
|
+
let options = MapInitOptions(
|
|
25
|
+
mapOptions: MapOptions(glyphsRasterizationOptions: GlyphsRasterizationOptions(rasterizationMode: .allGlyphsRasterizedLocally, fontFamily: nil)),
|
|
26
|
+
cameraOptions: cameraOptions)
|
|
26
27
|
|
|
27
28
|
mapView = MapView(frame: CGRect(x: 0, y: 0, width: 64, height: 64), mapInitOptions: options)
|
|
28
29
|
|
|
@@ -153,11 +153,13 @@ public class MapControlModule: RCTEventEmitter {
|
|
|
153
153
|
rejecter reject: RCTPromiseRejectBlock) {
|
|
154
154
|
return resolve(MapsIndoorsData.sharedInstance.mapView?.getMapControl()?.showUserPosition)
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
|
|
157
157
|
@objc public func goTo(_ entityJSON: String,
|
|
158
158
|
entityType: String,
|
|
159
|
+
maxZoom: NSNumber?,
|
|
159
160
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
160
161
|
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
162
|
+
|
|
161
163
|
var entity: MPEntity? = nil
|
|
162
164
|
do {
|
|
163
165
|
switch entityType {
|
|
@@ -175,7 +177,11 @@ public class MapControlModule: RCTEventEmitter {
|
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
DispatchQueue.main.async {
|
|
178
|
-
|
|
180
|
+
if maxZoom != -999 {
|
|
181
|
+
MapsIndoorsData.sharedInstance.mapView?.getMapControl()!.goTo(entity: entity!, maxZoom: maxZoom!.doubleValue)
|
|
182
|
+
} else {
|
|
183
|
+
MapsIndoorsData.sharedInstance.mapView?.getMapControl()!.goTo(entity: entity!)
|
|
184
|
+
}
|
|
179
185
|
return resolve(nil)
|
|
180
186
|
}
|
|
181
187
|
} catch let e {
|
|
@@ -126,4 +126,8 @@ RCT_EXTERN_METHOD(requiresMainQueueSetup)
|
|
|
126
126
|
RCT_EXTERN_METHOD(getSyncedVenues:(RCTPromiseResolveBlock)resolve
|
|
127
127
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
128
128
|
|
|
129
|
+
RCT_EXTERN_METHOD(cacheData:(NSString) apiKey
|
|
130
|
+
resolver:(RCTPromiseResolveBlock) resolve
|
|
131
|
+
rejecter:(RCTPromiseRejectBlock) reject)
|
|
132
|
+
|
|
129
133
|
@end
|
|
@@ -324,4 +324,39 @@ public class MapsIndoorsModule: NSObject {
|
|
|
324
324
|
func getSyncedVenues(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
325
325
|
return resolve(MPMapsIndoors.shared.venuesToSync)
|
|
326
326
|
}
|
|
327
|
+
|
|
328
|
+
@objc public func cacheData(_ apiKey: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
329
|
+
let datasetCacheManager = MPMapsIndoors.shared.datasetCacheManager
|
|
330
|
+
var dataSet = datasetCacheManager.dataSetWithId(apiKey)
|
|
331
|
+
if dataSet == nil {
|
|
332
|
+
dataSet = datasetCacheManager.addDataSet(apiKey, cachingScope: .full)
|
|
333
|
+
}
|
|
334
|
+
if dataSet == nil {
|
|
335
|
+
return resolve(false)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
datasetCacheManager.delegate = DatasetDelegate(promise: resolve, dataset: dataSet!.cacheItem)
|
|
340
|
+
|
|
341
|
+
datasetCacheManager.synchronizeCacheItems([dataSet!.cacheItem])
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
class DatasetDelegate: NSObject, MPDataSetCacheManagerDelegate {
|
|
347
|
+
var promise: RCTPromiseResolveBlock
|
|
348
|
+
var dataset: MPDataSetCacheItem
|
|
349
|
+
|
|
350
|
+
init(promise: @escaping RCTPromiseResolveBlock, dataset: MPDataSetCacheItem) {
|
|
351
|
+
self.promise = promise
|
|
352
|
+
self.dataset = dataset
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
func dataSetManager(_ dataSetManager: MPDataSetCacheManager, didFinishSynchronizingItem item: MPDataSetCacheItem) {
|
|
356
|
+
if item.cachingItemId == dataset.cachingItemId {
|
|
357
|
+
return promise(true)
|
|
358
|
+
}else {
|
|
359
|
+
return promise(false)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
327
362
|
}
|
package/package.json
CHANGED
|
@@ -24,6 +24,6 @@ Pod::Spec.new do |s|
|
|
|
24
24
|
s.requires_arc = true
|
|
25
25
|
|
|
26
26
|
s.dependency "React"
|
|
27
|
-
s.dependency "MapsIndoorsMapbox11", "4.9.
|
|
28
|
-
s.dependency "MapsIndoorsCodable", "4.9.
|
|
27
|
+
s.dependency "MapsIndoorsMapbox11", "4.9.3"
|
|
28
|
+
s.dependency "MapsIndoorsCodable", "4.9.3"
|
|
29
29
|
end
|
package/src/core/MapControl.ts
CHANGED
|
@@ -320,7 +320,7 @@ export default class MapControl {
|
|
|
320
320
|
if (maxZoom) {
|
|
321
321
|
return MapControlModule.goTo(JSON.stringify(entity), entity.type, maxZoom);
|
|
322
322
|
}
|
|
323
|
-
return MapControlModule.goTo(JSON.stringify(entity), entity.type);
|
|
323
|
+
return MapControlModule.goTo(JSON.stringify(entity), entity.type, -999);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
/**
|
package/src/core/MapsIndoors.ts
CHANGED
|
@@ -528,14 +528,28 @@ export default class MapsIndoors {
|
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
|
|
531
|
+
/**
|
|
532
|
+
* Add venues to the sync list.
|
|
533
|
+
* @param venues list of venueIds to add to sync.
|
|
534
|
+
* @returns
|
|
535
|
+
*/
|
|
531
536
|
public static async addVenuesToSync(venues: string[]): Promise<void> {
|
|
532
537
|
return MapsIndoorsModule.addVenuesToSync(venues);
|
|
533
538
|
}
|
|
534
539
|
|
|
540
|
+
/**
|
|
541
|
+
* Remove venues from the sync list.
|
|
542
|
+
* @param venues List of venueIds to remove from sync.
|
|
543
|
+
* @returns
|
|
544
|
+
*/
|
|
535
545
|
public static async removeVenuesToSync(venues: string[]): Promise<void> {
|
|
536
546
|
return MapsIndoorsModule.removeVenuesToSync(venues);
|
|
537
547
|
}
|
|
538
548
|
|
|
549
|
+
/**
|
|
550
|
+
* Get a list of venueIds that are synced.
|
|
551
|
+
* @returns Promise<string[]> A list of venueIds that are synced.
|
|
552
|
+
*/
|
|
539
553
|
public static async getSyncedVenues(): Promise<string[]> {
|
|
540
554
|
return MapsIndoorsModule.getSyncedVenues().then((venues: string[]|null) => {
|
|
541
555
|
if (venues === null || venues === undefined) {
|
|
@@ -545,4 +559,13 @@ export default class MapsIndoors {
|
|
|
545
559
|
}
|
|
546
560
|
});
|
|
547
561
|
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Cache all data for the current solution. Including tiles and images if present on the solution.
|
|
565
|
+
* @param apiKey The key to the MapsIndoors solution.
|
|
566
|
+
* @returns Promise<boolean> True if the caching was successful, otherwise false.
|
|
567
|
+
*/
|
|
568
|
+
public static async cacheData(apiKey: String): Promise<boolean> {
|
|
569
|
+
return MapsIndoorsModule.cacheData(apiKey);
|
|
570
|
+
}
|
|
548
571
|
}
|