@mapsindoors/react-native-maps-indoors-mapbox 2.0.4 → 2.0.5

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 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.0.4/index.html) to get an overview of what the MapsIndoors SDK offers.
5
+ Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.0.5/index.html) to get an overview of what the MapsIndoors SDK offers.
6
6
 
7
7
  ## Getting started
8
8
 
@@ -93,7 +93,7 @@ dependencies {
93
93
  }
94
94
 
95
95
  implementation 'com.mapbox.maps:android:11.4.0'
96
- implementation 'com.mapspeople.mapsindoors:mapbox-v11:4.8.7'
96
+ implementation 'com.mapspeople.mapsindoors:mapbox-v11:4.8.8'
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'
@@ -211,7 +211,7 @@ public class DirectionsRendererModule extends ReactContextBaseJavaModule impleme
211
211
  }
212
212
 
213
213
  @ReactMethod
214
- public void setRoute(String routeString, String icons, final Promise promise) {
214
+ public void setRoute(String routeString, String icons, int legIndex, final Promise promise) {
215
215
  if (mRenderer != null) {
216
216
  Context ctx = mCtx.getApplicationContext();
217
217
  MPRoute route = new Gson().fromJson(routeString, MPRoute.class);
@@ -238,7 +238,17 @@ public class DirectionsRendererModule extends ReactContextBaseJavaModule impleme
238
238
  iconConfigs.put(mapEntry.getKey(), iconConfig.toMPRouteStopIconConfig(ctx));
239
239
  }
240
240
  }
241
+
241
242
  mRenderer.setRoute(route, iconConfigs);
243
+ if (legIndex != 0) {
244
+ try {
245
+ mRenderer.selectLegIndex(legIndex);
246
+ } catch (IllegalStateException e) {
247
+ promise.reject(e.getMessage(), new Gson().toJson(MPError.fromMIError(new MIError(MIErrorEnum.ROUTING_UNKNOWN_ERROR, e.getMessage()))));
248
+ return;
249
+ }
250
+ }
251
+
242
252
  promise.resolve(null);
243
253
  });
244
254
  }else {
@@ -60,6 +60,7 @@ class MapBoxView: RCMapView {
60
60
 
61
61
  update = CameraOptions(cameraState: camera)
62
62
  update.center = point.coordinate
63
+
63
64
  case "fromBounds":
64
65
  guard let bounds = cameraUpdate.bounds else {
65
66
  throw CameraUpdateError.missingField("fromBounds", "bounds")
@@ -70,16 +71,19 @@ class MapBoxView: RCMapView {
70
71
 
71
72
  update = CameraOptions(cameraState: camera)
72
73
  update.center = camerabounds.bounds?.center
74
+
73
75
  case "zoomBy":
74
76
  let camera = mapboxView.mapboxMap.cameraState
75
77
 
76
78
  update = CameraOptions(cameraState: camera)
77
79
  update.zoom = CGFloat(cameraUpdate.zoom!)
80
+
78
81
  case "zoomTo":
79
82
  let camera = mapboxView.mapboxMap.cameraState
80
83
 
81
84
  update = CameraOptions(cameraState: camera)
82
85
  update.zoom = CGFloat(cameraUpdate.zoom!)
86
+
83
87
  case "fromCameraPosition":
84
88
  guard let position = cameraUpdate.position else {
85
89
  throw CameraUpdateError.missingField("fromCameraPosition", "position")
@@ -90,6 +94,8 @@ class MapBoxView: RCMapView {
90
94
  update.center = position.target.coordinate
91
95
  update.bearing = CLLocationDirection(position.bearing)
92
96
  update.zoom = CGFloat(position.zoom)
97
+ update.pitch = CGFloat(position.tilt)
98
+
93
99
  default:
94
100
  throw CameraUpdateError.unknownMode(cameraUpdate.mode)
95
101
  }
@@ -9,7 +9,7 @@ import MapsIndoors
9
9
 
10
10
  public struct CameraPosition: Codable {
11
11
  let zoom: Float
12
- let tilt: Float // TODO: this is called viewingAngle in MPCameraPosition(Codable)
12
+ let tilt: Float
13
13
  let bearing: Float
14
14
  let target: MPPoint
15
15
  }
@@ -46,6 +46,7 @@
46
46
 
47
47
  RCT_EXTERN_METHOD(setRoute: (NSString *) routeString
48
48
  stopIcons:(NSString *) stopIcons
49
+ legIndex: (nonnull NSNumber *) legIndex
49
50
  resolver:(RCTPromiseResolveBlock) resolve
50
51
  rejecter:(RCTPromiseRejectBlock) reject)
51
52
 
@@ -285,7 +285,7 @@ public class DirectionsRendererModule: RCTEventEmitter {
285
285
  return resolve(nil)
286
286
  }
287
287
 
288
- @objc public func setRoute(_ routeString: String, stopIcons: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
288
+ @objc public func setRoute(_ routeString: String, stopIcons: String, legIndex: NSNumber, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
289
289
  if (MapsIndoorsData.sharedInstance.directionsRenderer == nil) {
290
290
  MapsIndoorsData.sharedInstance.directionsRenderer = MapsIndoorsData.sharedInstance.mapView?.getMapControl()?.newDirectionsRenderer()
291
291
  }
@@ -303,6 +303,14 @@ public class DirectionsRendererModule: RCTEventEmitter {
303
303
  return doReject(reject, message: "Route could not be parsed")
304
304
  }
305
305
 
306
+ guard legIndex.intValue >= 0 else {
307
+ return doReject(reject, message: "Tried to select negative route leg index \(legIndex.intValue)")
308
+ }
309
+
310
+ guard legIndex.intValue < (route.legs.count) else {
311
+ return doReject(reject, message: "Tried to select route leg index \(legIndex.intValue) outside of range 0..\((route.legs.count)-1)")
312
+ }
313
+
306
314
  Task {
307
315
  var stopIconss: [Int: String]? = nil
308
316
  stopIconss = try? JSONDecoder().decode([Int: String].self, from: Data(stopIcons.utf8))
@@ -326,7 +334,7 @@ public class DirectionsRendererModule: RCTEventEmitter {
326
334
 
327
335
  DispatchQueue.main.sync {
328
336
  directionsRenderer.route = route
329
- directionsRenderer.routeLegIndex = 0
337
+ directionsRenderer.routeLegIndex = legIndex.intValue
330
338
  directionsRenderer.render(stopIcons: icons)
331
339
  }
332
340
 
@@ -94,7 +94,7 @@ public class DirectionsServiceModule: NSObject {
94
94
  query.stopsPoints = stops
95
95
 
96
96
  if(!directionsVars.excludeWayTypes.isEmpty) {
97
- query.avoidWayTypes = directionsVars.excludeWayTypes
97
+ query.excludeWayTypes = directionsVars.excludeWayTypes
98
98
  }
99
99
 
100
100
  if (directionsVars.date != nil) {
@@ -41,9 +41,9 @@ public class MapControlModule: RCTEventEmitter {
41
41
  return doReject(reject, message: "Mapview not available")
42
42
  }
43
43
 
44
+ MapsIndoorsData.sharedInstance.directionsRenderer?.clear()
45
+ MapsIndoorsData.sharedInstance.directionsRenderer = nil
44
46
  if mapView.getMapControl() != nil {
45
- MapsIndoorsData.sharedInstance.directionsRenderer?.clear()
46
- MapsIndoorsData.sharedInstance.directionsRenderer = nil
47
47
  return resolve(nil)
48
48
  }
49
49
 
@@ -69,6 +69,13 @@ class MapControlDelegate: MPMapControlDelegate, LiveDataDelegate, MPFloorSelecto
69
69
  }
70
70
 
71
71
  // MPMapControlDelegate:
72
+
73
+ func didChangeCameraPosition() -> Bool {
74
+ if (respondToCameraEvents) {
75
+ sendEvent(event: .cameraEvent, body: ["event": 5])
76
+ }
77
+ return true;
78
+ }
72
79
 
73
80
  func cameraIdle() -> Bool {
74
81
  if (respondToCameraEvents) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mapsindoors/react-native-maps-indoors-mapbox",
3
3
  "title": "React Native MapsIndoors Mapbox",
4
- "version": "2.0.4",
4
+ "version": "2.0.5",
5
5
  "description": "React Native MapsIndoors component with mapbox",
6
6
  "react-native": "index.ts",
7
7
  "files": [
@@ -24,7 +24,7 @@ Pod::Spec.new do |s|
24
24
  s.requires_arc = true
25
25
 
26
26
  s.dependency "React"
27
- s.dependency "MapsIndoorsMapbox11", "4.5.11"
28
- s.dependency "MapsIndoorsCodable", "4.5.11"
27
+ s.dependency "MapsIndoorsMapbox11", "4.5.12"
28
+ s.dependency "MapsIndoorsCodable", "4.5.12"
29
29
  end
30
30
 
@@ -88,16 +88,17 @@ export default class MPDirectionsRenderer {
88
88
  * @async
89
89
  * @param {?MPRoute} [route]
90
90
  * @param {RouteStopIconConfig[]} [stopIcons]
91
+ * @param {?number} [legIndex] Overwrites the starting leg index, when rendering the route
91
92
  * @returns {Promise<void>}
92
93
  */
93
- public async setRoute(route: MPRoute, stopIcons: Map<number, RouteStopIconConfig> = null): Promise<void> {
94
+ public async setRoute(route: MPRoute, stopIcons: Map<number, RouteStopIconConfig> = null, legIndex: number = 0): Promise<void> {
94
95
  var iconsAsString = new Map<number, string>();
95
96
  if (stopIcons !== null) {
96
97
  stopIcons.forEach((icon, index) => {
97
98
  iconsAsString.set(index, icon.getImage().toString());
98
99
  });
99
100
  }
100
- await DirectionsRenderer.setRoute(JSON.stringify(route), JSON.stringify(Object.fromEntries(iconsAsString.entries())));
101
+ await DirectionsRenderer.setRoute(JSON.stringify(route), JSON.stringify(Object.fromEntries(iconsAsString.entries())), legIndex);
101
102
  }
102
103
 
103
104
  /**
@@ -90,7 +90,7 @@ export default class MPPropertyData extends MPEntityInfo {
90
90
  object?.activeFrom,
91
91
  object?.activeTo,
92
92
  object?.contact,
93
- object?.imageUrl,
93
+ object?.imageURL,
94
94
  object?.locationType,
95
95
  object?.bookable,
96
96
  MPPoint.create(object?.anchor),
@@ -196,7 +196,7 @@ export interface MPPropertyDataParams {
196
196
  *
197
197
  * @type {?string}
198
198
  */
199
- imageUrl?: string,
199
+ imageURL?: string,
200
200
  /**
201
201
  * Internal - Documentation will follow.
202
202
  *