@rnmapbox/maps 10.0.0-beta.64 → 10.0.0-beta.66

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 (90) hide show
  1. package/android/rctmgl/.settings/org.eclipse.buildship.core.prefs +12 -1
  2. package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/modules/RCTMGLLocationModule.java +5 -0
  3. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +1 -1
  4. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSource.java +3 -6
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLLocationModule.kt +5 -0
  6. package/index.d.ts +37 -166
  7. package/ios/RCTMGL-v10/RCTMGLCamera.swift +113 -0
  8. package/ios/RCTMGL-v10/RCTMGLLocationModule.m +1 -0
  9. package/ios/RCTMGL-v10/RCTMGLLocationModule.swift +12 -3
  10. package/ios/RCTMGL-v10/RCTMGLLogging.swift +13 -0
  11. package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +87 -55
  12. package/ios/RCTMGL-v10/RCTMGLOfflineModule.swift +184 -66
  13. package/ios/RCTMGL-v10/RCTMGLStyleValue.swift +8 -1
  14. package/javascript/components/BackgroundLayer.tsx +91 -0
  15. package/javascript/components/CircleLayer.tsx +97 -0
  16. package/javascript/components/FillExtrusionLayer.tsx +95 -0
  17. package/javascript/components/FillLayer.tsx +91 -0
  18. package/javascript/components/HeatmapLayer.tsx +96 -0
  19. package/javascript/components/NativeUserLocation.tsx +33 -0
  20. package/javascript/components/RasterLayer.tsx +88 -0
  21. package/javascript/components/SkyLayer.tsx +70 -0
  22. package/javascript/components/UserLocation.js +11 -0
  23. package/javascript/modules/location/locationManager.js +23 -2
  24. package/javascript/modules/offline/offlineManager.js +1 -1
  25. package/lib/commonjs/components/BackgroundLayer.js +6 -55
  26. package/lib/commonjs/components/BackgroundLayer.js.map +1 -1
  27. package/lib/commonjs/components/CircleLayer.js +8 -58
  28. package/lib/commonjs/components/CircleLayer.js.map +1 -1
  29. package/lib/commonjs/components/FillExtrusionLayer.js +3 -55
  30. package/lib/commonjs/components/FillExtrusionLayer.js.map +1 -1
  31. package/lib/commonjs/components/FillLayer.js +2 -55
  32. package/lib/commonjs/components/FillLayer.js.map +1 -1
  33. package/lib/commonjs/components/HeatmapLayer.js +3 -56
  34. package/lib/commonjs/components/HeatmapLayer.js.map +1 -1
  35. package/lib/commonjs/components/NativeUserLocation.js +6 -31
  36. package/lib/commonjs/components/NativeUserLocation.js.map +1 -1
  37. package/lib/commonjs/components/RasterLayer.js +1 -53
  38. package/lib/commonjs/components/RasterLayer.js.map +1 -1
  39. package/lib/commonjs/components/SkyLayer.js +2 -43
  40. package/lib/commonjs/components/SkyLayer.js.map +1 -1
  41. package/lib/commonjs/components/UserLocation.js +10 -0
  42. package/lib/commonjs/components/UserLocation.js.map +1 -1
  43. package/lib/commonjs/modules/location/locationManager.js +16 -1
  44. package/lib/commonjs/modules/location/locationManager.js.map +1 -1
  45. package/lib/commonjs/modules/offline/offlineManager.js +1 -1
  46. package/lib/module/components/BackgroundLayer.js +6 -55
  47. package/lib/module/components/BackgroundLayer.js.map +1 -1
  48. package/lib/module/components/CircleLayer.js +7 -57
  49. package/lib/module/components/CircleLayer.js.map +1 -1
  50. package/lib/module/components/FillExtrusionLayer.js +2 -54
  51. package/lib/module/components/FillExtrusionLayer.js.map +1 -1
  52. package/lib/module/components/FillLayer.js +1 -54
  53. package/lib/module/components/FillLayer.js.map +1 -1
  54. package/lib/module/components/HeatmapLayer.js +2 -55
  55. package/lib/module/components/HeatmapLayer.js.map +1 -1
  56. package/lib/module/components/NativeUserLocation.js +4 -30
  57. package/lib/module/components/NativeUserLocation.js.map +1 -1
  58. package/lib/module/components/RasterLayer.js +1 -53
  59. package/lib/module/components/RasterLayer.js.map +1 -1
  60. package/lib/module/components/SkyLayer.js +1 -42
  61. package/lib/module/components/SkyLayer.js.map +1 -1
  62. package/lib/module/components/UserLocation.js +10 -0
  63. package/lib/module/components/UserLocation.js.map +1 -1
  64. package/lib/module/modules/location/locationManager.js +17 -2
  65. package/lib/module/modules/location/locationManager.js.map +1 -1
  66. package/lib/module/modules/offline/offlineManager.js +1 -1
  67. package/lib/typescript/components/BackgroundLayer.d.ts +62 -0
  68. package/lib/typescript/components/BackgroundLayer.d.ts.map +1 -0
  69. package/lib/typescript/components/CircleLayer.d.ts +66 -0
  70. package/lib/typescript/components/CircleLayer.d.ts.map +1 -0
  71. package/lib/typescript/components/FillExtrusionLayer.d.ts +65 -0
  72. package/lib/typescript/components/FillExtrusionLayer.d.ts.map +1 -0
  73. package/{javascript/components/FillLayer.js → lib/typescript/components/FillLayer.d.ts} +28 -57
  74. package/lib/typescript/components/FillLayer.d.ts.map +1 -0
  75. package/lib/typescript/components/HeatmapLayer.d.ts +66 -0
  76. package/lib/typescript/components/HeatmapLayer.d.ts.map +1 -0
  77. package/lib/typescript/components/NativeUserLocation.d.ts +22 -0
  78. package/lib/typescript/components/NativeUserLocation.d.ts.map +1 -0
  79. package/lib/typescript/components/RasterLayer.d.ts +62 -0
  80. package/lib/typescript/components/RasterLayer.d.ts.map +1 -0
  81. package/lib/typescript/components/SkyLayer.d.ts +52 -0
  82. package/lib/typescript/components/SkyLayer.d.ts.map +1 -0
  83. package/package.json +1 -1
  84. package/javascript/components/BackgroundLayer.js +0 -97
  85. package/javascript/components/CircleLayer.js +0 -101
  86. package/javascript/components/FillExtrusionLayer.js +0 -98
  87. package/javascript/components/HeatmapLayer.js +0 -99
  88. package/javascript/components/NativeUserLocation.js +0 -41
  89. package/javascript/components/RasterLayer.js +0 -95
  90. package/javascript/components/SkyLayer.js +0 -80
@@ -1,2 +1,13 @@
1
- connection.project.dir=../../example/android
1
+ arguments=--init-script /var/folders/nf/xt27lc4j4sv73tqskhkd_8xc0000gn/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/nf/xt27lc4j4sv73tqskhkd_8xc0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
2
+ auto.sync=false
3
+ build.scans.enabled=false
4
+ connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.4.2))
5
+ connection.project.dir=
2
6
  eclipse.preferences.version=1
7
+ gradle.user.home=
8
+ java.home=/Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home
9
+ jvm.arguments=
10
+ offline.mode=false
11
+ override.workspace.settings=true
12
+ show.console.view=true
13
+ show.executions.view=true
@@ -94,6 +94,11 @@ public class RCTMGLLocationModule extends ReactContextBaseJavaModule {
94
94
  }
95
95
  }
96
96
 
97
+ @ReactMethod
98
+ public void setRequestsAlwaysUse(boolean requestsAlwaysUse) {
99
+ // IOS only. Ignored on Android.
100
+ }
101
+
97
102
  @ReactMethod
98
103
  public void stop() {
99
104
  stopLocationManager();
@@ -93,7 +93,7 @@ class RCTMGLCamera(private val mContext: Context, private val mManager: RCTMGLCa
93
93
  override fun onAnimationStart(animator: Animator) {}
94
94
  override fun onAnimationEnd(animator: Animator) {
95
95
  if (!hasSentFirstRegion) {
96
- mMapView!!.sendRegionChangeEvent(false)
96
+ mMapView?.sendRegionChangeEvent(false)
97
97
  hasSentFirstRegion = true
98
98
  }
99
99
  }
@@ -73,9 +73,6 @@ public class RCTMGLVectorSource extends RCTMGLTileSource<VectorSource> {
73
73
  return;
74
74
  }
75
75
 
76
-
77
- WritableMap payload = new WritableNativeMap();
78
-
79
76
  mMap.querySourceFeatures(
80
77
  getID(),
81
78
  new SourceQueryOptions(layerIDs, filter),
@@ -83,6 +80,7 @@ public class RCTMGLVectorSource extends RCTMGLTileSource<VectorSource> {
83
80
  new QueryFeaturesCallback() {
84
81
  @Override
85
82
  public void run(@NonNull Expected<String, List<QueriedFeature>> queriedFeatures) {
83
+ WritableMap payload = new WritableNativeMap();
86
84
  if (queriedFeatures.isError()) {
87
85
  //V10todo
88
86
  payload.putString("error", queriedFeatures.getError());
@@ -93,11 +91,10 @@ public class RCTMGLVectorSource extends RCTMGLTileSource<VectorSource> {
93
91
  }
94
92
  payload.putString("data", FeatureCollection.fromFeatures(features).toJson());
95
93
  }
94
+ AndroidCallbackEvent event = new AndroidCallbackEvent(RCTMGLVectorSource.this, callbackID, payload);
95
+ mManager.handleEvent(event);
96
96
  }
97
97
  }
98
98
  );
99
-
100
- AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
101
- mManager.handleEvent(event);
102
99
  }
103
100
  }
@@ -87,6 +87,11 @@ class RCTMGLLocationModule(reactContext: ReactApplicationContext) :
87
87
  }
88
88
  }
89
89
 
90
+ @ReactMethod
91
+ fun setRequestsAlwaysUse(requestsAlwaysUse: Boolean) {
92
+ // IOS only. Ignored on Android.
93
+ }
94
+
90
95
  @ReactMethod
91
96
  fun stop() {
92
97
  stopLocationManager()
package/index.d.ts CHANGED
@@ -24,7 +24,14 @@ import {
24
24
 
25
25
  import type {
26
26
  SymbolLayerStyleProps,
27
+ CircleLayerStyleProps,
28
+ FillExtrusionLayerStyleProps,
29
+ SkyLayerStyleProps,
30
+ RasterLayerStyleProps,
31
+ HeatmapLayerStyleProps,
32
+ FillLayerStyleProps,
27
33
  LineLayerStyleProps,
34
+ BackgroundLayerStyleProps,
28
35
  } from './javascript/utils/MapboxStyles';
29
36
  import { getAnnotationsLayerID as _getAnnotationsLayerID } from './javascript/utils/getAnnotationsLayerID';
30
37
  import {
@@ -47,10 +54,16 @@ import {
47
54
  SymbolLayer as _SymbolLayer,
48
55
  Props as _SymbolLayerProps,
49
56
  } from './javascript/components/SymbolLayer';
50
- import {
51
- LineLayer as _LineLayer,
57
+ import _LineLayer, {
52
58
  Props as _LineLayerProps,
53
59
  } from './javascript/components/LineLayer';
60
+ import { Props as _BackgroundLayerProps } from './javascript/components/BackgroundLayer';
61
+ import { Props as _CircleLayerProps } from './javascript/components/CircleLayer';
62
+ import { Props as _FillLayerProps } from './javascript/components/FillLayer';
63
+ import { Props as _FillExtrusionLayerProps } from './javascript/components/FillExtrusionLayer';
64
+ import { Props as _RasterLayerProps } from './javascript/components/RasterLayer';
65
+ import { Props as _HeatmapLayerProps } from './javascript/components/HeatmapLayer';
66
+ import { Props as _SkyLayerProps } from './javascript/components/SkyLayer';
54
67
  import {
55
68
  ShapeSource as _ShapeSource,
56
69
  Props as _ShapeSourceProps,
@@ -111,17 +124,6 @@ type Visibility = 'visible' | 'none';
111
124
  type Alignment = 'map' | 'viewport';
112
125
  type AutoAlignment = Alignment | 'auto';
113
126
 
114
- type NamedStyles<T> = {
115
- [P in keyof T]:
116
- | SymbolLayerStyleProps
117
- | RasterLayerStyle
118
- | LineLayerStyleProps
119
- | FillLayerStyle
120
- | FillExtrusionLayerStyle
121
- | CircleLayerStyle
122
- | BackgroundLayerStyle;
123
- };
124
-
125
127
  export type OnPressEvent = {
126
128
  features: Array<GeoJSON.Feature>;
127
129
  coordinates: {
@@ -281,13 +283,13 @@ declare namespace MapboxGL {
281
283
  class ImageSource extends Component<ImageSourceProps> {}
282
284
 
283
285
  // layers
284
- class FillLayer extends Component<FillLayerProps> {}
285
- class FillExtrusionLayer extends Component<FillExtrusionLayerProps> {}
286
+ class FillLayer extends Component<_FillLayerProps> {}
287
+ class FillExtrusionLayer extends Component<_FillExtrusionLayerProps> {}
286
288
  class LineLayer extends Component<_LineLayerProps> {}
287
- class CircleLayer extends Component<CircleLayerProps> {}
289
+ class CircleLayer extends Component<_CircleLayerProps> {}
288
290
  class SymbolLayer extends Component<_SymbolLayerProps> {}
289
- class RasterLayer extends Component<RasterLayerProps> {}
290
- class BackgroundLayer extends Component<BackgroundLayerProps> {}
291
+ class RasterLayer extends Component<_RasterLayerProps> {}
292
+ class BackgroundLayer extends Component<_BackgroundLayerProps> {}
291
293
  }
292
294
 
293
295
  /**
@@ -370,26 +372,6 @@ declare namespace MapboxGL {
370
372
 
371
373
  class Light extends Component<LightProps> {}
372
374
 
373
- class StyleSheet extends Component {
374
- static create<T extends NamedStyles<T> | NamedStyles<any>>(styles: T): T;
375
- camera(
376
- stops: { [key: number]: string },
377
- interpolationMode?: InterpolationMode,
378
- ): void;
379
- source(
380
- stops: { [key: number]: string },
381
- attributeName: string,
382
- interpolationMode?: InterpolationMode,
383
- ): void;
384
- composite(
385
- stops: { [key: number]: string },
386
- attributeName: string,
387
- interpolationMode?: InterpolationMode,
388
- ): void;
389
-
390
- identity(attributeName: string): number;
391
- }
392
-
393
375
  class Callout extends Component<CalloutProps> {}
394
376
  type Style = React.FC<StyleProps>;
395
377
 
@@ -403,16 +385,16 @@ declare namespace MapboxGL {
403
385
  /**
404
386
  * Layers
405
387
  */
406
- class BackgroundLayer extends Component<BackgroundLayerProps> {}
407
- class CircleLayer extends Component<CircleLayerProps> {}
408
- class FillExtrusionLayer extends Component<FillExtrusionLayerProps> {}
409
- class FillLayer extends Component<FillLayerProps> {}
410
- class LineLayer extends Component<LineLayerProps> {}
411
- class RasterLayer extends Component<RasterLayerProps> {}
412
- class HeatmapLayer extends Component<HeatmapLayerProps> {}
388
+ class BackgroundLayer extends Component<_BackgroundLayerProps> {}
389
+ class CircleLayer extends Component<_CircleLayerProps> {}
390
+ class FillExtrusionLayer extends Component<_FillExtrusionLayerProps> {}
391
+ class FillLayer extends Component<_FillLayerProps> {}
392
+ class LineLayer extends Component<_LineLayerProps> {}
393
+ class RasterLayer extends Component<_RasterLayerProps> {}
394
+ class HeatmapLayer extends Component<_HeatmapLayerProps> {}
413
395
  class Images extends Component<ImagesProps> {}
414
396
  class ImageSource extends Component<ImageSourceProps> {}
415
- class SkyLayer extends Component<SkyLayerProps> {}
397
+ class SkyLayer extends Component<_SkyLayerProps> {}
416
398
 
417
399
  class LocationManager extends Component {
418
400
  start(displacement?: number): void;
@@ -612,6 +594,7 @@ export interface UserLocationProps {
612
594
  animated?: boolean;
613
595
  children?: ReactNode;
614
596
  minDisplacement?: number;
597
+ requestsAlwaysUse?: boolean;
615
598
  onPress?: () => void;
616
599
  onUpdate?: (location: MapboxGL.Location) => void;
617
600
  renderMode?: 'normal' | 'native';
@@ -638,121 +621,19 @@ export interface Transition {
638
621
  delay: number;
639
622
  }
640
623
 
641
- export interface BackgroundLayerStyle {
642
- visibility?: Visibility | Expression;
643
- backgroundColor?: string | Expression;
644
- backgroundColorTransition?: Transition | Expression;
645
- backgroundPattern?: string | Expression;
646
- backgroundPatternTransition?: Transition | Expression;
647
- backgroundOpacity?: number | Expression;
648
- backgroundOpacityTransition?: Transition | Expression;
649
- }
624
+ export type BackgroundLayerStyle = BackgroundLayerStyleProps;
650
625
 
651
- export interface CircleLayerStyle {
652
- visibility?: Visibility | Expression;
653
- circleRadius?: number | Expression;
654
- circleRadiusTransition?: Transition | Expression;
655
- circleColor?: string | Expression;
656
- circleColorTransition?: Transition | Expression;
657
- circleBlur?: number | Expression;
658
- circleBlurTransition?: Transition | Expression;
659
- circleOpacity?: number | Expression;
660
- circleOpacityTransition?: Transition | Expression;
661
- circleTranslate?: Array<number> | Expression;
662
- circleTranslateTransition?: Transition | Expression;
663
- circleTranslateAnchor?: Alignment | Expression;
664
- circlePitchScale?: Alignment | Expression;
665
- circlePitchAlignment?: Alignment | Expression;
666
- circleStrokeWidth?: number | Expression;
667
- circleStrokeWidthTransition?: Transition | Expression;
668
- circleStrokeColor?: string | Expression;
669
- circleStrokeColorTransition?: Transition | Expression;
670
- circleStrokeOpacity?: number | Expression;
671
- circleStrokeOpacityTransition?: Transition | Expression;
672
- }
626
+ export type CircleLayerStyle = CircleLayerStyleProps;
673
627
 
674
- export interface FillExtrusionLayerStyle {
675
- visibility?: Visibility | Expression;
676
- fillExtrusionOpacity?: number | Expression;
677
- fillExtrusionOpacityTransition?: Transition | Expression;
678
- fillExtrusionColor?: string | Expression;
679
- fillExtrusionColorTransition?: Transition | Expression;
680
- fillExtrusionTranslate?: Array<number> | Expression;
681
- fillExtrusionTranslateTransition?: Transition | Expression;
682
- fillExtrusionTranslateAnchor?: Alignment | Expression;
683
- fillExtrusionPattern?: string | Expression;
684
- fillExtrusionPatternTransition?: Transition | Expression;
685
- fillExtrusionHeight?: number | Expression;
686
- fillExtrusionHeightTransition?: Transition | Expression;
687
- fillExtrusionBase?: number | Expression;
688
- fillExtrusionBaseTransition?: Transition | Expression;
689
- }
628
+ export type FillExtrusionLayerStyle = FillExtrusionLayerStyleProps;
690
629
 
691
- export interface FillLayerStyle {
692
- visibility?: Visibility | Expression;
693
- fillAntialias?: boolean | Expression;
694
- fillOpacity?: number | Expression;
695
- fillExtrusionOpacityTransition?: Transition | Expression;
696
- fillColor?: string | Expression;
697
- fillColorTransition?: Transition | Expression;
698
- fillOutlineColor?: string | Expression;
699
- fillOutlineColorTransition?: Transition | Expression;
700
- fillTranslate?: Array<number> | Expression;
701
- fillTranslateTransition?: Transition | Expression;
702
- fillTranslateAnchor?: Alignment | Expression;
703
- fillPattern?: string | Expression;
704
- fillPatternTransition?: Transition | Expression;
705
- }
630
+ export type FillLayerStyle = FillLayerStyleProps;
706
631
 
707
- export interface SkyLayerStyle {
708
- skyType: string | Expression;
709
- skyAtmosphereSun?: Array<number> | Expression;
710
- skyAtmosphereSunIntensity: number | Expression;
711
- }
632
+ export type SkyLayerStyle = SkyLayerStyleProps;
712
633
 
713
- export interface LineLayerStyle {
714
- lineCap?: 'butt' | 'round' | 'square' | Expression;
715
- lineJoin?: 'bevel' | 'round' | 'miter' | Expression;
716
- lineMiterLimit?: number | Expression;
717
- lineRoundLimit?: number | Expression;
718
- visibility?: Visibility | Expression;
719
- lineOpacity?: number | Expression;
720
- lineOpacityTransition?: Transition | Expression;
721
- lineColor?: string | Expression;
722
- lineColorTransition?: Transition | Expression;
723
- lineTranslate?: Array<number> | Expression;
724
- lineTranslateTransition?: Transition | Expression;
725
- lineTranslateAnchor?: Alignment | Expression;
726
- lineWidth?: number | Expression;
727
- lineWidthTransition?: Transition | Expression;
728
- lineGapWidth?: number | Expression;
729
- lineGapWidthTransition?: Transition | Expression;
730
- lineOffset?: number | Expression;
731
- lineOffsetTransition?: Transition | Expression;
732
- lineBlur?: number | Expression;
733
- lineBlurTransition?: Transition | Expression;
734
- lineDasharray?: Array<number> | Expression;
735
- lineDasharrayTransition?: Transition | Expression;
736
- linePattern?: string | Expression;
737
- linePatternTransition?: Transition | Expression;
738
- }
634
+ export type LineLayerStyle = LineLayerStyleProps;
739
635
 
740
- export interface RasterLayerStyle {
741
- visibility?: Visibility | Expression;
742
- rasterOpacity?: number | Expression;
743
- rasterOpacityTransition?: Transition | Expression;
744
- rasterHueRotate?: Expression;
745
- rasterHueRotateTransition?: Transition | Expression;
746
- rasterBrightnessMin?: number | Expression;
747
- rasterBrightnessMinTransition?: Transition | Expression;
748
- rasterBrightnessMax?: number | Expression;
749
- rasterBrightnessMaxTransition?: Transition | Expression;
750
- rasterSaturation?: number | Expression;
751
- rasterSaturationTransition?: Transition | Expression;
752
- rasterContrast?: number | Expression;
753
- rasterContrastTransition?: Transition | Expression;
754
- rasterFadeDuration?: number | Expression;
755
- }
636
+ export type RasterLayerStyle = RasterLayerStyleProps;
756
637
 
757
638
  export type TextVariableAnchorValues =
758
639
  | 'center'
@@ -768,17 +649,7 @@ export type TextVariableAnchorValues =
768
649
  export type SymbolLayerStyle = SymbolLayerStyleProps;
769
650
  export type LineLayerStyle = LineLayerStyleProps;
770
651
 
771
- export interface HeatmapLayerStyle {
772
- visibility?: Visibility | Expression;
773
- heatmapRadius?: number | Expression;
774
- heatmapRadiusTransition?: Transition | Expression;
775
- heatmapWeight?: number | Expression;
776
- heatmapIntensity?: number | Expression;
777
- heatmapIntensityTransition?: Transition | Expression;
778
- heatmapColor?: string | Expression;
779
- heatmapOpacity?: number | Expression;
780
- heatmapOpacityTransition?: Transition | Expression;
781
- }
652
+ export type HeatmapLayerStyle = HeatmapLayerStyleProps;
782
653
 
783
654
  export interface Point {
784
655
  x: number;
@@ -123,28 +123,35 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
123
123
  _updateCameraFromTrackingMode()
124
124
  }
125
125
  }
126
+
126
127
  @objc var followUserMode: String? {
127
128
  didSet {
128
129
  _updateCameraFromTrackingMode()
129
130
  }
130
131
  }
132
+
131
133
  @objc var followUserLocation : Bool = false {
132
134
  didSet {
133
135
  _updateCameraFromTrackingMode()
134
136
  }
135
137
  }
138
+
136
139
  @objc var followZoomLevel: NSNumber? {
137
140
  didSet {
138
141
  _updateCameraFromTrackingMode()
139
142
  }
140
143
  }
144
+
141
145
  @objc var maxZoomLevel: NSNumber? {
142
146
  didSet { _updateMaxBounds() }
143
147
  }
148
+
144
149
  @objc var minZoomLevel: NSNumber? {
145
150
  didSet { _updateMaxBounds() }
146
151
  }
152
+
147
153
  @objc var onUserTrackingModeChange: RCTBubblingEventBlock? = nil
154
+
148
155
  @objc var stop: [String: Any]? {
149
156
  didSet {
150
157
  _updateCamera()
@@ -319,6 +326,7 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
319
326
  }
320
327
  let followState = map.viewport.makeFollowPuckViewportState(options: followOptions)
321
328
  map.viewport.transition(to: followState)
329
+ map.viewport.addStatusObserver(self)
322
330
  map.mapboxMap.setCamera(to: _camera)
323
331
  }
324
332
  }
@@ -468,6 +476,11 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
468
476
  map.reactCamera = self
469
477
  }
470
478
 
479
+ override func removeFromMap(_ map: RCTMGLMapView) {
480
+ map.viewport.removeStatusObserver(self)
481
+ super.removeFromMap(map)
482
+ }
483
+
471
484
  // MARK: - LocationConsumer
472
485
 
473
486
  func locationUpdate(newLocation: Location) {
@@ -495,6 +508,106 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
495
508
  }
496
509
  }
497
510
 
511
+ // MARK: - ViewportStatusObserver
512
+
513
+ extension RCTMGLCamera : ViewportStatusObserver {
514
+ func toDict(_ status: ViewportStatus) -> [String: Any] {
515
+ switch (status) {
516
+ case .idle:
517
+ return ["state":"idle"]
518
+ case .state(let state):
519
+ return ["state":String(describing: type(of: state))]
520
+ case .transition(let transition, toState: let toState):
521
+ return [
522
+ "transition": String(describing: type(of: transition)),
523
+ "state":String(describing: type(of: toState))
524
+ ]
525
+ }
526
+ }
527
+
528
+ func toFollowUserLocation(_ status: ViewportStatus) -> Bool {
529
+ switch status {
530
+ case .idle:
531
+ return false
532
+ case .state(_):
533
+ return true
534
+ case .transition(_, toState: _):
535
+ return true
536
+ }
537
+ }
538
+
539
+ func toFollowUserMode(_ state: ViewportState) -> String? {
540
+ if let state = state as? FollowPuckViewportState {
541
+ switch state.options.bearing {
542
+ case .heading:
543
+ return "compass"
544
+ case .course:
545
+ return "course"
546
+ case .some(let bearing):
547
+ return "constant"
548
+ case .none:
549
+ return "normal"
550
+ }
551
+ } else if let state = state as? OverviewViewportState {
552
+ return "overview"
553
+ } else {
554
+ return "custom"
555
+ }
556
+ }
557
+
558
+ func toFollowUserMode(_ status: ViewportStatus) -> String? {
559
+ switch status {
560
+ case .idle:
561
+ return nil
562
+ case .state(let state):
563
+ return toFollowUserMode(state)
564
+ case .transition(_, toState: let state):
565
+ return toFollowUserMode(state)
566
+ }
567
+ }
568
+
569
+ func toString(_ reason: ViewportStatusChangeReason) -> String {
570
+ if reason == .idleRequested {
571
+ return "idleRequested"
572
+ } else if reason == .transitionFailed {
573
+ return "transitionFailied"
574
+ } else if reason == .transitionStarted {
575
+ return "transitionStarted"
576
+ } else if reason == .transitionSucceeded {
577
+ return "transitionSucceeded"
578
+ } else if reason == .userInteraction {
579
+ return "userInteraction"
580
+ } else {
581
+ return "unkown \(reason)"
582
+ }
583
+ }
584
+
585
+ func viewportStatusDidChange(from fromStatus: ViewportStatus,
586
+ to toStatus: ViewportStatus,
587
+ reason: ViewportStatusChangeReason)
588
+ {
589
+ if (reason == .userInteraction) {
590
+ followUserLocation = toFollowUserLocation(toStatus)
591
+
592
+ if let onUserTrackingModeChange = onUserTrackingModeChange {
593
+ let event = RCTMGLEvent(
594
+ type: .onUserTrackingModeChange,
595
+ payload: [
596
+ "followUserMode": toFollowUserMode(toStatus) as Any,
597
+ "followUserLocation": followUserLocation,
598
+ "fromViewportStatus": toDict(fromStatus),
599
+ "toViewportState": toDict(toStatus),
600
+ "reason": toString(reason)
601
+ ]
602
+ )
603
+
604
+ onUserTrackingModeChange(event.toJSON())
605
+ }
606
+ }
607
+ }
608
+ }
609
+
498
610
  private func toSeconds(_ ms: Double) -> TimeInterval {
499
611
  return ms * 0.001
500
612
  }
613
+
@@ -10,6 +10,7 @@ RCT_EXTERN_METHOD(stop)
10
10
  RCT_EXTERN_METHOD(getLastKnownLocation)
11
11
 
12
12
  RCT_EXTERN_METHOD(setMinDisplacement:(CLLocationDistance)minDisplacement)
13
+ RCT_EXTERN_METHOD(setRequestsAlwaysUse:(BOOL)requestsAlwaysUse)
13
14
 
14
15
 
15
16
  @end
@@ -52,6 +52,7 @@ class RCTMGLLocationManager : LocationProviderDelegate {
52
52
 
53
53
  var lastKnownLocation : CLLocation?
54
54
  var lastKnownHeading : CLHeading?
55
+ var shouldRequestAlwaysAuthorization: Bool?
55
56
 
56
57
  weak var delegate: RCTMGLLocationManagerDelegate?
57
58
  weak var locationProviderDelage: LocationProviderDelegate?
@@ -67,8 +68,14 @@ class RCTMGLLocationManager : LocationProviderDelegate {
67
68
  provider.locationProviderOptions = options
68
69
  }
69
70
 
71
+ func setRequestsAlwaysUse(_ requestsAlwaysUse: Bool) {
72
+ shouldRequestAlwaysAuthorization = requestsAlwaysUse;
73
+ }
74
+
70
75
  func start() {
71
- provider.requestAlwaysAuthorization()
76
+ if shouldRequestAlwaysAuthorization == true {
77
+ provider.requestAlwaysAuthorization()
78
+ }
72
79
  provider.requestWhenInUseAuthorization()
73
80
  provider.setDelegate(self)
74
81
  provider.startUpdatingHeading()
@@ -266,6 +273,10 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
266
273
  locationManager.setDistanceFilter(minDisplacement)
267
274
  }
268
275
 
276
+ @objc func setRequestsAlwaysUse(_ requestsAlwaysUse: Bool) {
277
+ locationManager.setRequestsAlwaysUse(requestsAlwaysUse);
278
+ }
279
+
269
280
  @objc
270
281
  override func startObserving() {
271
282
  super.startObserving()
@@ -278,7 +289,6 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
278
289
  hasListener = false
279
290
  }
280
291
 
281
-
282
292
  func locationManager(_ locationManager: RCTMGLLocationManager, didUpdateLocation location: RCTMGLLocation) {
283
293
  guard hasListener else {
284
294
  return
@@ -290,5 +300,4 @@ class RCTMGLLocationModule: RCTEventEmitter, RCTMGLLocationManagerDelegate {
290
300
 
291
301
  self.sendEvent(withName: RCT_MAPBOX_USER_LOCATION_UPDATE, body: location.toJSON())
292
302
  }
293
-
294
303
  }
@@ -81,6 +81,19 @@ func errorMessage(_ error: Error) -> String {
81
81
  }
82
82
  }
83
83
 
84
+ /// log message if optional returned by `fn` is nil
85
+ func logged<T>(_ msg: String, info: (() -> String)? = nil, level: Logger.LogLevel = .error, rejecter: RCTPromiseRejectBlock? = nil, fn: () -> T?) ->T? {
86
+ let ret = fn()
87
+ if ret == nil {
88
+ Logger.log(level:level, message: "\(msg) \(info?() ?? "")")
89
+ rejecter?(msg, "\(info?() ?? "")", NSError(domain:"is null", code: 0))
90
+ return nil
91
+ } else {
92
+ return ret
93
+ }
94
+ }
95
+
96
+ /// log message if `fn` throws and return nil
84
97
  func logged<T>(_ msg: String, info: (() -> String)? = nil, level: Logger.LogLevel = .error, rejecter: RCTPromiseRejectBlock? = nil, fn : () throws -> T) -> T? {
85
98
  do {
86
99
  return try fn()