@mapsindoors/react-native-maps-indoors-mapbox 1.0.2 → 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.
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/1.0.2/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/1.0.3/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:10.14.1'
96
- implementation 'com.mapspeople.mapsindoors:mapbox:4.1.11'
96
+ implementation 'com.mapspeople.mapsindoors:mapbox:4.2.2'
97
97
  implementation 'com.facebook.react:react-native:+' // From node_modules
98
98
  implementation 'androidx.core:core-ktx:1.3.2'
99
99
  }
@@ -136,12 +136,12 @@ afterEvaluate { project ->
136
136
  }
137
137
 
138
138
  task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
139
- classifier = 'javadoc'
139
+ archiveClassifier = 'javadoc'
140
140
  from androidJavadoc.destinationDir
141
141
  }
142
142
 
143
143
  task androidSourcesJar(type: Jar) {
144
- classifier = 'sources'
144
+ archiveClassifier = 'sources'
145
145
  from android.sourceSets.main.java.srcDirs
146
146
  include '**/*.java'
147
147
  }
@@ -109,6 +109,16 @@ public class DirectionsRendererModule extends ReactContextBaseJavaModule impleme
109
109
  }
110
110
  }
111
111
 
112
+ @ReactMethod
113
+ public void showRouteLegButtons(boolean value, final Promise promise) {
114
+ if (mRenderer != null) {
115
+ mRenderer.showRouteLegButtons(value);
116
+ promise.resolve(null);
117
+ } else {
118
+ rejectPromise(promise);
119
+ }
120
+ }
121
+
112
122
  @ReactMethod
113
123
  public void setCameraAnimationDuration(int duration, final Promise promise) {
114
124
  if (mRenderer != null) {
@@ -1,5 +1,6 @@
1
1
  package com.reactlibrary.core;
2
2
 
3
+ import android.graphics.Typeface;
3
4
  import android.view.View;
4
5
 
5
6
  import androidx.annotation.NonNull;
@@ -399,6 +400,13 @@ public class MapControlModule extends ReactContextBaseJavaModule implements MPCa
399
400
  promise.resolve(null);
400
401
  }
401
402
 
403
+ @ReactMethod
404
+ public void setLabelOptions(int textSize, String color, boolean showHalo, final Promise promise) {
405
+ mMapControl.setMapLabelFont(Typeface.DEFAULT, color, showHalo);
406
+ mMapControl.setMapLabelTextSize(textSize);
407
+ promise.resolve(null);
408
+ }
409
+
402
410
  //region listeners
403
411
 
404
412
  @ReactMethod
@@ -54,4 +54,8 @@
54
54
  resolver:(RCTPromiseResolveBlock) resolve
55
55
  rejecter:(RCTPromiseRejectBlock) reject)
56
56
 
57
+ RCT_EXTERN_METHOD(showRouteLegButtons: (BOOL) value
58
+ resolver:(RCTPromiseResolveBlock) resolve
59
+ rejecter:(RCTPromiseRejectBlock) reject)
60
+
57
61
  @end
@@ -14,6 +14,7 @@ public class DirectionsRendererModule: RCTEventEmitter {
14
14
  private var directionsRenderer: MPDirectionsRenderer? = nil
15
15
  private var isListeningForLegChanges: Bool = false
16
16
  private var animationDuration: NSNumber = 5
17
+ private var showRouteLabel: Bool = true
17
18
 
18
19
  @objc public override static func requiresMainQueueSetup() -> Bool { return false }
19
20
 
@@ -159,7 +160,25 @@ public class DirectionsRendererModule: RCTEventEmitter {
159
160
 
160
161
  return resolve(nil)
161
162
  }
162
-
163
+
164
+ @objc public func showRouteLegButtons(_ value: Bool, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
165
+ if (directionsRenderer == nil) {
166
+ directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
167
+ }
168
+
169
+ guard let directionsRenderer else {
170
+ return doReject(reject, message: "directions renderer null. MapControl needs to have been instantiated first")
171
+ }
172
+
173
+ if !value {
174
+ showRouteLabel = value
175
+ }else {
176
+ showRouteLabel = true
177
+ }
178
+
179
+ return resolve(nil)
180
+ }
181
+
163
182
  @objc public func setCameraAnimationDuration(_ duration: NSNumber, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
164
183
  if (directionsRenderer != nil) {
165
184
  directionsRenderer = MapsIndoorsData.sharedInstance.mapControl?.newDirectionsRenderer()
@@ -138,6 +138,12 @@
138
138
  resolver:(RCTPromiseResolveBlock) resolve
139
139
  rejecter:(RCTPromiseRejectBlock) reject)
140
140
 
141
+ RCT_EXTERN_METHOD(setLabelOptions:(NSInteger) textSize
142
+ color:(NSString) color
143
+ showHalo:(BOOL) showHalo
144
+ resolver:(RCTPromiseResolveBlock) resolve
145
+ rejecter:(RCTPromiseRejectBlock) reject)
146
+
141
147
  // Set Listeners
142
148
 
143
149
  RCT_EXTERN_METHOD(setOnMapClickListener:(BOOL) setup
@@ -8,7 +8,21 @@ import React
8
8
  @objc(MapControlModule)
9
9
  public class MapControlModule: RCTEventEmitter {
10
10
  @objc override public static func requiresMainQueueSetup() -> Bool {return false}
11
-
11
+
12
+ enum HexParsingError: Error {
13
+ case invalidHexString(String)
14
+ }
15
+ func colorFromHexString(hex: String) throws -> UIColor {
16
+ let regex = try! NSRegularExpression(pattern: "^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{8}$")
17
+ let range = NSRange(location: 0, length: hex.utf16.count)
18
+
19
+ if (regex.matches(in: hex, range: range).count == 1) {
20
+ return UIColor(fromHexString: hex)!
21
+ } else {
22
+ throw HexParsingError.invalidHexString(hex)
23
+ }
24
+ }
25
+
12
26
  private var mapConfig: MPMapConfig? = nil
13
27
 
14
28
  /// Base overide for RCTEventEmitter.
@@ -512,4 +526,29 @@ public class MapControlModule: RCTEventEmitter {
512
526
  return doReject(reject, error: e)
513
527
  }
514
528
  }
529
+
530
+ @objc public func setLabelOptions(_ textSize: Int,
531
+ color: String,
532
+ showHalo: Bool,
533
+ resolver resolve: @escaping RCTPromiseResolveBlock,
534
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
535
+
536
+ let mapsIndoorsData = MapsIndoorsData.sharedInstance
537
+ guard let mapControl = mapsIndoorsData.mapControl else {
538
+ return doReject(reject, message: "mapControl is not available")
539
+ }
540
+
541
+ let haloWidth: Float = showHalo ? 5.0 : 0.0
542
+ let haloBlur: Float = showHalo ? 5.0 : 0.0
543
+ let haloColor = UIColor.white
544
+
545
+ do {
546
+ let textColor = try colorFromHexString(hex: color)
547
+ mapControl.setMapLabelFont(font: UIFont.systemFont(ofSize: CGFloat(textSize)), textSize: Float(textSize), color: textColor, labelHaloColor: haloColor, labelHaloWidth: haloWidth, labelHaloBlur: haloBlur)
548
+ return resolve(nil)
549
+
550
+ } catch {
551
+ return doReject(reject, error: error)
552
+ }
553
+ }
515
554
  }
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": "1.0.2",
4
+ "version": "1.0.3",
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 "MapsIndoorsMapbox", "4.2.4"
28
- s.dependency "MapsIndoorsCodable", "4.2.4"
27
+ s.dependency "MapsIndoorsMapbox", "4.2.5"
28
+ s.dependency "MapsIndoorsCodable", "4.2.5"
29
29
  end
30
30
 
@@ -101,6 +101,18 @@ export default class MPDirectionsRenderer {
101
101
  await DirectionsRenderer.setAnimatedPolyline(animated, repeating, durationMs);
102
102
  }
103
103
 
104
+ /**
105
+ * Enable/Disable the route end/start label buttons from showing on the route. Default is true
106
+ *
107
+ * @public
108
+ * @async
109
+ * @param {boolean} show
110
+ * @returns {Promise<void>}
111
+ */
112
+ public async showRouteLegButtons(show: boolean): Promise<void> {
113
+ await DirectionsRenderer.showRouteLegButtons(show);
114
+ }
115
+
104
116
  /**
105
117
  * Manually set the selected leg index on the route.
106
118
  *
@@ -861,4 +861,16 @@ export default class MapControl {
861
861
  MapControlModule.setOnFloorUpdateListener(false);
862
862
  }
863
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
+ }
864
876
  }