@rnmapbox/maps 10.0.0-beta.41 → 10.0.0-beta.43
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/.eslintrc.js +2 -1
- package/.github/workflows/ios-actions.yml +1 -1
- package/android/install.md +20 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +22 -31
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java +26 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphere.kt +59 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphereManager.kt +30 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrain.kt +32 -27
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrainManager.kt +5 -11
- package/docs/Annotations.md +4 -3
- package/docs/Camera.md +1 -1
- package/docs/HeadingIndicator.md +1 -1
- package/docs/MapView.md +2 -2
- package/docs/SymbolLayer.md +4 -3
- package/docs/Terrain.md +64 -9
- package/docs/docs.json +66 -53
- package/index.d.ts +13 -80
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +28 -26
- package/ios/RCTMGL-v10/RCTMGLImages.swift +1 -99
- package/ios/RCTMGL-v10/RCTMGLLogging.swift +8 -0
- package/ios/RCTMGL-v10/RCTMGLMapView.swift +35 -39
- package/ios/RCTMGL-v10/RCTMGLSingletonLayer.swift +7 -1
- package/ios/RCTMGL-v10/RCTMGLStyle.swift +34 -0
- package/ios/RCTMGL-v10/RCTMGLTerrain.swift +56 -63
- package/ios/RCTMGL-v10/RCTMGLTerrainManager.m +2 -3
- package/javascript/components/AbstractLayer.tsx +72 -0
- package/javascript/components/BackgroundLayer.js +1 -1
- package/javascript/components/Camera.tsx +17 -1
- package/javascript/components/CircleLayer.js +1 -1
- package/javascript/components/FillExtrusionLayer.js +1 -1
- package/javascript/components/FillLayer.js +1 -1
- package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +5 -6
- package/javascript/components/HeatmapLayer.js +1 -1
- package/javascript/components/LineLayer.js +1 -1
- package/javascript/components/MapView.js +8 -12
- package/javascript/components/RasterLayer.js +1 -1
- package/javascript/components/SkyLayer.js +1 -1
- package/javascript/components/SymbolLayer.tsx +113 -0
- package/javascript/components/Terrain.tsx +52 -0
- package/javascript/components/UserLocation.js +1 -1
- package/javascript/global.d.ts +4 -0
- package/javascript/index.js +8 -4
- package/javascript/types/index.ts +0 -14
- package/javascript/utils/MapboxStyles.ts +177 -52
- package/javascript/utils/StyleValue.ts +8 -6
- package/javascript/utils/deprecation.ts +39 -0
- package/javascript/utils/{filterUtils.js → filterUtils.tsx} +1 -1
- package/javascript/utils/styleMap.ts +26 -0
- package/package.json +6 -6
- package/scripts/autogenHelpers/DocJSONBuilder.js +2 -3
- package/scripts/autogenHelpers/globals.js +20 -7
- package/scripts/autogenerate.js +13 -0
- package/scripts/templates/MapboxStyles.ts.ejs +8 -3
- package/scripts/templates/RCTMGLStyleFactoryv10.java.ejs +1 -0
- package/.eslintignore +0 -1
- package/javascript/components/AbstractLayer.js +0 -46
- package/javascript/components/SymbolLayer.js +0 -120
- package/javascript/components/Terrain.js +0 -56
- package/javascript/utils/deprecation.js +0 -24
package/docs/docs.json
CHANGED
|
@@ -696,9 +696,12 @@
|
|
|
696
696
|
{
|
|
697
697
|
"name": "onUserTrackingModeChange",
|
|
698
698
|
"required": false,
|
|
699
|
-
"type":
|
|
699
|
+
"type": {
|
|
700
|
+
"name": "func",
|
|
701
|
+
"funcSignature": "(event:MapboxGLEvent) => void"
|
|
702
|
+
},
|
|
700
703
|
"default": "none",
|
|
701
|
-
"description": "Executes when user tracking mode changes
|
|
704
|
+
"description": "Executes when user tracking mode changes.\n*signature:*`(event:MapboxGLEvent) => void`"
|
|
702
705
|
}
|
|
703
706
|
],
|
|
704
707
|
"fileNameWithExt": "Camera.tsx",
|
|
@@ -1643,7 +1646,7 @@
|
|
|
1643
1646
|
"description": "FIX ME NO DESCRIPTION"
|
|
1644
1647
|
}
|
|
1645
1648
|
],
|
|
1646
|
-
"fileNameWithExt": "HeadingIndicator.
|
|
1649
|
+
"fileNameWithExt": "HeadingIndicator.tsx",
|
|
1647
1650
|
"name": "HeadingIndicator"
|
|
1648
1651
|
},
|
|
1649
1652
|
"HeatmapLayer": {
|
|
@@ -3055,34 +3058,14 @@
|
|
|
3055
3058
|
"required": false,
|
|
3056
3059
|
"type": "func",
|
|
3057
3060
|
"default": "none",
|
|
3058
|
-
"description": "iOS, v10 only,
|
|
3059
|
-
"params": [
|
|
3060
|
-
{
|
|
3061
|
-
"name": "region",
|
|
3062
|
-
"description": "A payload containing the map center, bounds, and other properties.",
|
|
3063
|
-
"type": {
|
|
3064
|
-
"name": "MapState"
|
|
3065
|
-
},
|
|
3066
|
-
"optional": false
|
|
3067
|
-
}
|
|
3068
|
-
]
|
|
3061
|
+
"description": "iOS, v10 only, deprecated will be removed in next version - please use onRegionIsChanging."
|
|
3069
3062
|
},
|
|
3070
3063
|
{
|
|
3071
3064
|
"name": "onMapIdle",
|
|
3072
3065
|
"required": false,
|
|
3073
3066
|
"type": "func",
|
|
3074
3067
|
"default": "none",
|
|
3075
|
-
"description": "iOS, v10 only,
|
|
3076
|
-
"params": [
|
|
3077
|
-
{
|
|
3078
|
-
"name": "region",
|
|
3079
|
-
"description": "A payload containing the map center, bounds, and other properties.",
|
|
3080
|
-
"type": {
|
|
3081
|
-
"name": "MapState"
|
|
3082
|
-
},
|
|
3083
|
-
"optional": false
|
|
3084
|
-
}
|
|
3085
|
-
]
|
|
3068
|
+
"description": "iOS, v10 only, deprecated will be removed in next version - please use onRegionDidChange"
|
|
3086
3069
|
},
|
|
3087
3070
|
{
|
|
3088
3071
|
"name": "onWillStartLoadingMap",
|
|
@@ -4428,7 +4411,7 @@
|
|
|
4428
4411
|
{
|
|
4429
4412
|
"name": "filter",
|
|
4430
4413
|
"required": false,
|
|
4431
|
-
"type": "
|
|
4414
|
+
"type": "Array",
|
|
4432
4415
|
"default": "none",
|
|
4433
4416
|
"description": "Filter only the features in the source layer that satisfy a condition that you define"
|
|
4434
4417
|
},
|
|
@@ -4448,16 +4431,20 @@
|
|
|
4448
4431
|
},
|
|
4449
4432
|
{
|
|
4450
4433
|
"name": "style",
|
|
4434
|
+
"required": true,
|
|
4435
|
+
"type": "SymbolLayerStyleProps",
|
|
4436
|
+
"default": "none",
|
|
4437
|
+
"description": "FIX ME NO DESCRIPTION"
|
|
4438
|
+
},
|
|
4439
|
+
{
|
|
4440
|
+
"name": "children",
|
|
4451
4441
|
"required": false,
|
|
4452
|
-
"type": "
|
|
4442
|
+
"type": "JSX.Element \\| JSX.Element[]",
|
|
4453
4443
|
"default": "none",
|
|
4454
|
-
"description": "
|
|
4444
|
+
"description": "FIX ME NO DESCRIPTION"
|
|
4455
4445
|
}
|
|
4456
4446
|
],
|
|
4457
|
-
"
|
|
4458
|
-
"../utils"
|
|
4459
|
-
],
|
|
4460
|
-
"fileNameWithExt": "SymbolLayer.js",
|
|
4447
|
+
"fileNameWithExt": "SymbolLayer.tsx",
|
|
4461
4448
|
"name": "SymbolLayer",
|
|
4462
4449
|
"styles": [
|
|
4463
4450
|
{
|
|
@@ -5795,40 +5782,66 @@
|
|
|
5795
5782
|
]
|
|
5796
5783
|
},
|
|
5797
5784
|
"Terrain": {
|
|
5798
|
-
"description": "
|
|
5785
|
+
"description": "",
|
|
5799
5786
|
"displayName": "Terrain",
|
|
5800
|
-
"methods": [
|
|
5801
|
-
{
|
|
5802
|
-
"name": "baseProps",
|
|
5803
|
-
"docblock": null,
|
|
5804
|
-
"modifiers": [
|
|
5805
|
-
"get"
|
|
5806
|
-
],
|
|
5807
|
-
"params": [],
|
|
5808
|
-
"returns": null
|
|
5809
|
-
}
|
|
5810
|
-
],
|
|
5787
|
+
"methods": [],
|
|
5811
5788
|
"props": [
|
|
5812
5789
|
{
|
|
5813
5790
|
"name": "sourceID",
|
|
5814
|
-
"required":
|
|
5791
|
+
"required": true,
|
|
5815
5792
|
"type": "string",
|
|
5816
|
-
"default": "
|
|
5793
|
+
"default": "none",
|
|
5817
5794
|
"description": "Name of a source of raster_dem type to be used for terrain elevation."
|
|
5818
5795
|
},
|
|
5819
5796
|
{
|
|
5820
5797
|
"name": "exaggeration",
|
|
5821
5798
|
"required": false,
|
|
5822
|
-
"type": "
|
|
5799
|
+
"type": "Value",
|
|
5823
5800
|
"default": "none",
|
|
5824
|
-
"description": "
|
|
5801
|
+
"description": "Deprecated, use exaggeration in style instead"
|
|
5802
|
+
},
|
|
5803
|
+
{
|
|
5804
|
+
"name": "style",
|
|
5805
|
+
"required": true,
|
|
5806
|
+
"type": "TerrainLayerStyleProps",
|
|
5807
|
+
"default": "none",
|
|
5808
|
+
"description": "Customizable style attributes"
|
|
5825
5809
|
}
|
|
5826
5810
|
],
|
|
5827
|
-
"
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5811
|
+
"fileNameWithExt": "Terrain.tsx",
|
|
5812
|
+
"name": "Terrain",
|
|
5813
|
+
"styles": [
|
|
5814
|
+
{
|
|
5815
|
+
"name": "source",
|
|
5816
|
+
"type": "string",
|
|
5817
|
+
"values": [],
|
|
5818
|
+
"description": "Name of a source of `raster_dem` type to be used for terrain elevation.",
|
|
5819
|
+
"requires": [],
|
|
5820
|
+
"disabledBy": [],
|
|
5821
|
+
"allowedFunctionTypes": []
|
|
5822
|
+
},
|
|
5823
|
+
{
|
|
5824
|
+
"name": "exaggeration",
|
|
5825
|
+
"type": "number",
|
|
5826
|
+
"values": [],
|
|
5827
|
+
"minimum": 0,
|
|
5828
|
+
"maximum": 1000,
|
|
5829
|
+
"default": 1,
|
|
5830
|
+
"description": "Exaggerates the elevation of the terrain by multiplying the data from the DEM with this value.",
|
|
5831
|
+
"requires": [
|
|
5832
|
+
"source"
|
|
5833
|
+
],
|
|
5834
|
+
"disabledBy": [],
|
|
5835
|
+
"allowedFunctionTypes": [],
|
|
5836
|
+
"expression": {
|
|
5837
|
+
"interpolated": true,
|
|
5838
|
+
"parameters": [
|
|
5839
|
+
"zoom"
|
|
5840
|
+
]
|
|
5841
|
+
},
|
|
5842
|
+
"transition": true
|
|
5843
|
+
}
|
|
5844
|
+
]
|
|
5832
5845
|
},
|
|
5833
5846
|
"UserLocation": {
|
|
5834
5847
|
"description": "",
|
package/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
FeatureCollection,
|
|
23
23
|
} from '@turf/helpers';
|
|
24
24
|
|
|
25
|
+
import type { SymbolLayerStyleProps } from './javascript/utils/MapboxStyles';
|
|
25
26
|
import {
|
|
26
27
|
Camera as _Camera,
|
|
27
28
|
CameraStop as _CameraStop,
|
|
@@ -32,14 +33,18 @@ import {
|
|
|
32
33
|
CameraBoundsWithPadding as _CameraBoundsWithPadding,
|
|
33
34
|
CameraStops as _CameraStops,
|
|
34
35
|
CameraAnimationMode as _CameraAnimationMode,
|
|
36
|
+
type UserTrackingMode as _UserTrackingMode,
|
|
37
|
+
type UserTrackingModeChangeCallback as _UserTrackingModeChangeCallback,
|
|
35
38
|
} from './javascript/components/Camera';
|
|
36
39
|
import { MarkerView as _MarkerView } from './javascript/components/MarkerView';
|
|
37
40
|
import { PointAnnotation as _PointAnnotation } from './javascript/components/PointAnnotation';
|
|
38
41
|
import { Atmosphere as _Atmosphere } from './javascript/components/Atmosphere';
|
|
42
|
+
import {
|
|
43
|
+
SymbolLayer as _SymbolLayer,
|
|
44
|
+
Props as _SymbolLayerProps,
|
|
45
|
+
} from './javascript/components/SymbolLayer';
|
|
39
46
|
import type {
|
|
40
47
|
MapboxGLEvent as _MapboxGLEvent,
|
|
41
|
-
UserTrackingMode as _UserTrackingMode,
|
|
42
|
-
UserTrackingModeChangeCallback as _UserTrackingModeChangeCallback,
|
|
43
48
|
AnimatedPoint as _AnimatedPoint,
|
|
44
49
|
AnimatedShape as _AnimatedShape,
|
|
45
50
|
} from './javascript/types/index';
|
|
@@ -96,7 +101,7 @@ type AutoAlignment = Alignment | 'auto';
|
|
|
96
101
|
|
|
97
102
|
type NamedStyles<T> = {
|
|
98
103
|
[P in keyof T]:
|
|
99
|
-
|
|
|
104
|
+
| SymbolLayerStyleProps
|
|
100
105
|
| RasterLayerStyle
|
|
101
106
|
| LineLayerStyle
|
|
102
107
|
| FillLayerStyle
|
|
@@ -142,6 +147,7 @@ declare namespace MapboxGL {
|
|
|
142
147
|
const Atmosphere = _Atmosphere;
|
|
143
148
|
const MarkerView = _MarkerView;
|
|
144
149
|
const PointAnnotation = _PointAnnotation;
|
|
150
|
+
const SymbolLayer = _SymbolLayer;
|
|
145
151
|
|
|
146
152
|
type MapboxGLEvent = _MapboxGLEvent;
|
|
147
153
|
type UserTrackingMode = _UserTrackingMode;
|
|
@@ -246,7 +252,7 @@ declare namespace MapboxGL {
|
|
|
246
252
|
class FillExtrusionLayer extends Component<FillExtrusionLayerProps> {}
|
|
247
253
|
class LineLayer extends Component<LineLayerProps> {}
|
|
248
254
|
class CircleLayer extends Component<CircleLayerProps> {}
|
|
249
|
-
class SymbolLayer extends Component<
|
|
255
|
+
class SymbolLayer extends Component<_SymbolLayerProps> {}
|
|
250
256
|
class RasterLayer extends Component<RasterLayerProps> {}
|
|
251
257
|
class BackgroundLayer extends Component<BackgroundLayerProps> {}
|
|
252
258
|
}
|
|
@@ -397,7 +403,6 @@ declare namespace MapboxGL {
|
|
|
397
403
|
class FillLayer extends Component<FillLayerProps> {}
|
|
398
404
|
class LineLayer extends Component<LineLayerProps> {}
|
|
399
405
|
class RasterLayer extends Component<RasterLayerProps> {}
|
|
400
|
-
class SymbolLayer extends Component<SymbolLayerProps> {}
|
|
401
406
|
class HeatmapLayer extends Component<HeatmapLayerProps> {}
|
|
402
407
|
class Images extends Component<ImagesProps> {}
|
|
403
408
|
class ImageSource extends Component<ImageSourceProps> {}
|
|
@@ -482,11 +487,6 @@ declare namespace MapboxGL {
|
|
|
482
487
|
/**
|
|
483
488
|
* Constants
|
|
484
489
|
*/
|
|
485
|
-
enum UserTrackingModes {
|
|
486
|
-
Follow = 'normal',
|
|
487
|
-
FollowWithHeading = 'compass',
|
|
488
|
-
FollowWithCourse = 'course',
|
|
489
|
-
}
|
|
490
490
|
|
|
491
491
|
enum InterpolationMode {
|
|
492
492
|
Exponential = 0,
|
|
@@ -757,75 +757,8 @@ export type TextVariableAnchorValues =
|
|
|
757
757
|
| 'bottom-left'
|
|
758
758
|
| 'bottom-right';
|
|
759
759
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
symbolSpacing?: number | Expression;
|
|
763
|
-
symbolAvoidEdges?: boolean | Expression;
|
|
764
|
-
symbolSortKey?: number | Expression;
|
|
765
|
-
symbolZOrder?: 'auto' | 'viewport-y' | 'source' | Expression;
|
|
766
|
-
iconAllowOverlap?: boolean | Expression;
|
|
767
|
-
iconIgnorePlacement?: boolean | Expression;
|
|
768
|
-
iconOptional?: boolean | Expression;
|
|
769
|
-
iconRotationAlignment?: AutoAlignment | Expression;
|
|
770
|
-
iconSize?: number | Expression;
|
|
771
|
-
iconTextFit?: 'none' | 'width' | 'height' | 'both' | Expression;
|
|
772
|
-
iconTextFitPadding?: Array<number> | Expression;
|
|
773
|
-
iconImage?: string | Expression;
|
|
774
|
-
iconRotate?: number | Expression;
|
|
775
|
-
iconPadding?: number | Expression;
|
|
776
|
-
iconKeepUpright?: boolean | Expression;
|
|
777
|
-
iconOffset?: Array<number> | Expression;
|
|
778
|
-
iconAnchor?: Anchor | Expression;
|
|
779
|
-
iconPitchAlignment?: AutoAlignment | Expression;
|
|
780
|
-
textPitchAlignment?: AutoAlignment | Expression;
|
|
781
|
-
textRotationAlignment?: AutoAlignment | Expression;
|
|
782
|
-
textField?: string | Expression;
|
|
783
|
-
textFont?: Array<string> | Expression;
|
|
784
|
-
textSize?: number | Expression;
|
|
785
|
-
textMaxWidth?: number | Expression;
|
|
786
|
-
textLineHeight?: number | Expression;
|
|
787
|
-
textLetterSpacing?: number | Expression;
|
|
788
|
-
textJustify?: 'left' | 'center' | 'right' | Expression;
|
|
789
|
-
textAnchor?: Anchor | Expression;
|
|
790
|
-
textMaxAngle?: number | Expression;
|
|
791
|
-
textRotate?: number | Expression;
|
|
792
|
-
textPadding?: number | Expression;
|
|
793
|
-
textKeepUpright?: boolean | Expression;
|
|
794
|
-
textTransform?: 'none' | 'uppercase' | 'lowercase' | Expression;
|
|
795
|
-
textOffset?: Array<number> | Expression;
|
|
796
|
-
textAllowOverlap?: boolean | Expression;
|
|
797
|
-
textIgnorePlacement?: boolean | Expression;
|
|
798
|
-
textOptional?: boolean | Expression;
|
|
799
|
-
textVariableAnchor?: Array<TextVariableAnchorValues>;
|
|
800
|
-
textRadialOffset?: number | Expression;
|
|
801
|
-
visibility?: Visibility | Expression;
|
|
802
|
-
iconOpacity?: number | Expression;
|
|
803
|
-
iconOpacityTransition?: Transition | Expression;
|
|
804
|
-
iconColor?: string | Expression;
|
|
805
|
-
iconColorTransition?: Transition | Expression;
|
|
806
|
-
iconHaloColor?: string | Expression;
|
|
807
|
-
iconHaloColorTransition?: Transition | Expression;
|
|
808
|
-
iconHaloWidth?: number | Expression;
|
|
809
|
-
iconHaloWidthTransition?: Transition | Expression;
|
|
810
|
-
iconHaloBlur?: number | Expression;
|
|
811
|
-
iconHaloBlurTransition?: Transition | Expression;
|
|
812
|
-
iconTranslate?: Array<number> | Expression;
|
|
813
|
-
iconTranslateTransition?: Transition | Expression;
|
|
814
|
-
iconTranslateAnchor?: Alignment | Expression;
|
|
815
|
-
textOpacity?: number | Expression;
|
|
816
|
-
textOpacityTransition?: Transition | Expression;
|
|
817
|
-
textColor?: string | Expression;
|
|
818
|
-
textColorTransition?: Transition | Expression;
|
|
819
|
-
textHaloColor?: string | Expression;
|
|
820
|
-
textHaloColorTransition?: Transition | Expression;
|
|
821
|
-
textHaloWidth?: number | Expression;
|
|
822
|
-
textHaloWidthTransition?: Transition | Expression;
|
|
823
|
-
textHaloBlur?: number | Expression;
|
|
824
|
-
textHaloBlurTransition?: Transition | Expression;
|
|
825
|
-
textTranslate?: Array<number> | Expression;
|
|
826
|
-
textTranslateTransition?: Transition | Expression;
|
|
827
|
-
textTranslateAnchor?: Alignment | Expression;
|
|
828
|
-
}
|
|
760
|
+
/** @deprecated Will be removed in next betas */
|
|
761
|
+
export type SymbolLayerStyle = SymbolLayerStyleProps;
|
|
829
762
|
|
|
830
763
|
export interface HeatmapLayerStyle {
|
|
831
764
|
visibility?: Visibility | Expression;
|
|
@@ -943,7 +876,7 @@ export interface RasterLayerProps extends LayerBaseProps {
|
|
|
943
876
|
}
|
|
944
877
|
|
|
945
878
|
export interface SymbolLayerProps extends LayerBaseProps {
|
|
946
|
-
style?:
|
|
879
|
+
style?: SymbolLayerStyleProps;
|
|
947
880
|
}
|
|
948
881
|
|
|
949
882
|
export interface HeatmapLayerProps extends LayerBaseProps {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
-
|
|
2
|
+
import MapboxMaps
|
|
3
3
|
import Turf
|
|
4
4
|
|
|
5
|
-
protocol RCTMGLMapComponent :
|
|
5
|
+
protocol RCTMGLMapComponent : AnyObject {
|
|
6
6
|
func addToMap(_ map: RCTMGLMapView, style: Style)
|
|
7
7
|
func removeFromMap(_ map: RCTMGLMapView)
|
|
8
8
|
|
|
@@ -13,6 +13,10 @@ enum CameraMode: String, CaseIterable {
|
|
|
13
13
|
case flight, ease, linear, none
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
enum UserTrackingMode: String {
|
|
17
|
+
case none,compass, course, normal
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
struct CameraUpdateItem {
|
|
17
21
|
var camera: CameraOptions
|
|
18
22
|
var mode: CameraMode
|
|
@@ -25,10 +29,7 @@ struct CameraUpdateItem {
|
|
|
25
29
|
}
|
|
26
30
|
switch mode {
|
|
27
31
|
case .flight:
|
|
28
|
-
|
|
29
|
-
_camera.padding = nil
|
|
30
|
-
map.camera.fly(to: _camera, duration: duration)
|
|
31
|
-
changePadding(map: map, cameraAnimator: &cameraAnimator, curve: .linear)
|
|
32
|
+
map.camera.fly(to: camera, duration: duration)
|
|
32
33
|
case .ease:
|
|
33
34
|
map.camera.ease(to: camera, duration: duration ?? 0, curve: .easeInOut, completion: nil)
|
|
34
35
|
case .linear:
|
|
@@ -38,18 +39,6 @@ struct CameraUpdateItem {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
/// Padding is not currently animatable on the camera's `fly(to:)` method, so we create a separate animator instead.
|
|
43
|
-
/// If this changes, remove this and call `fly(to:)` with an unmodified `camera`.
|
|
44
|
-
func changePadding(map: RCTMGLMapView, cameraAnimator: inout BasicCameraAnimator?, curve: UIView.AnimationCurve) {
|
|
45
|
-
if let cameraAnimator = cameraAnimator {
|
|
46
|
-
cameraAnimator.stopAnimation()
|
|
47
|
-
}
|
|
48
|
-
cameraAnimator = map.camera.makeAnimator(duration: duration ?? 0, curve: curve) { (transition) in
|
|
49
|
-
transition.padding.toValue = camera.padding
|
|
50
|
-
}
|
|
51
|
-
cameraAnimator?.startAnimation()
|
|
52
|
-
}
|
|
53
42
|
}
|
|
54
43
|
|
|
55
44
|
class CameraUpdateQueue {
|
|
@@ -133,7 +122,7 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
|
|
|
133
122
|
_updateCameraFromTrackingMode()
|
|
134
123
|
}
|
|
135
124
|
}
|
|
136
|
-
@objc var followUserMode:
|
|
125
|
+
@objc var followUserMode: String? {
|
|
137
126
|
didSet {
|
|
138
127
|
_updateCameraFromTrackingMode()
|
|
139
128
|
}
|
|
@@ -192,11 +181,22 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
|
|
|
192
181
|
}
|
|
193
182
|
}
|
|
194
183
|
|
|
184
|
+
func _disableUsetTracking(_ map: MapView) {
|
|
185
|
+
map.viewport.idle()
|
|
186
|
+
map.location.removeLocationConsumer(consumer: self)
|
|
187
|
+
}
|
|
188
|
+
|
|
195
189
|
func _updateCameraFromTrackingMode() {
|
|
196
190
|
withMapView { map in
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
let userTrackingMode = UserTrackingMode(rawValue: self.followUserMode ?? "none")
|
|
192
|
+
guard let userTrackingMode = userTrackingMode else {
|
|
193
|
+
Logger.error("RCTMGLCamera: Unexpected followUserMode \(optional: self.followUserMode)")
|
|
194
|
+
self._disableUsetTracking(map)
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
guard self.followUserLocation && userTrackingMode != .none else {
|
|
199
|
+
self._disableUsetTracking(map)
|
|
200
200
|
return
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -207,17 +207,20 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
|
|
|
207
207
|
map.location.addLocationConsumer(newConsumer: self)
|
|
208
208
|
var trackingModeChanged = false
|
|
209
209
|
var followOptions = FollowPuckViewportStateOptions()
|
|
210
|
-
|
|
210
|
+
switch userTrackingMode {
|
|
211
|
+
case .none:
|
|
212
|
+
Logger.assert("RCTMGLCamera, userTrackingModes should not be none here")
|
|
213
|
+
case .compass:
|
|
211
214
|
map.location.options.puckBearingEnabled = true
|
|
212
215
|
map.location.options.puckBearingSource = PuckBearingSource.heading
|
|
213
216
|
followOptions.bearing = FollowPuckViewportStateBearing.heading
|
|
214
217
|
trackingModeChanged = true
|
|
215
|
-
|
|
218
|
+
case .course:
|
|
216
219
|
map.location.options.puckBearingEnabled = true
|
|
217
220
|
map.location.options.puckBearingSource = PuckBearingSource.course
|
|
218
221
|
followOptions.bearing = FollowPuckViewportStateBearing.course
|
|
219
222
|
trackingModeChanged = true
|
|
220
|
-
|
|
223
|
+
case .normal:
|
|
221
224
|
map.location.options.puckBearingEnabled = false
|
|
222
225
|
followOptions.bearing = nil
|
|
223
226
|
trackingModeChanged = true
|
|
@@ -436,7 +439,6 @@ class RCTMGLCamera : RCTMGLMapComponentBase, LocationConsumer {
|
|
|
436
439
|
}
|
|
437
440
|
}
|
|
438
441
|
|
|
439
|
-
/// Converts milliseconds to seconds.
|
|
440
442
|
private func toSeconds(_ ms: Double) -> TimeInterval {
|
|
441
443
|
return ms * 0.001
|
|
442
444
|
}
|
|
@@ -69,7 +69,7 @@ class RCTMGLImages : UIView, RCTMGLMapComponent {
|
|
|
69
69
|
return false
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
public func sendImageMissingEvent(imageName: String,
|
|
72
|
+
public func sendImageMissingEvent(imageName: String, payload: StyleImageMissingPayload) {
|
|
73
73
|
let payload = ["imageKey":imageName]
|
|
74
74
|
let event = RCTMGLEvent(type: .imageMissing, payload: payload)
|
|
75
75
|
if let onImageMissing = onImageMissing {
|
|
@@ -97,101 +97,3 @@ class RCTMGLImages : UIView, RCTMGLMapComponent {
|
|
|
97
97
|
}()
|
|
98
98
|
|
|
99
99
|
}
|
|
100
|
-
/*
|
|
101
|
-
#import "RCTMGLImages.h"
|
|
102
|
-
#import "UIView+React.h"
|
|
103
|
-
#import "RCTMGLMapView.h"
|
|
104
|
-
#import "RCTMGLUtils.h"
|
|
105
|
-
#import "RCTMGLEvent.h"
|
|
106
|
-
#import "RCTMGLEventTypes.h"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
@implementation RCTMGLImages : UIView
|
|
110
|
-
|
|
111
|
-
static UIImage * _placeHolderImage;
|
|
112
|
-
|
|
113
|
-
- (void)addToMap
|
|
114
|
-
{
|
|
115
|
-
if (self.map.style == nil) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
[self _addNativeImages:_nativeImages];
|
|
119
|
-
[self _addRemoteImages:_images];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
- (void)removeFromMap
|
|
123
|
-
{
|
|
124
|
-
if (self.map.style == nil) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
[self _removeImages];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
- (void)_removeImages
|
|
132
|
-
{
|
|
133
|
-
if ([self _hasImages]) {
|
|
134
|
-
NSArray<NSString *> *imageNames = _images.allKeys;
|
|
135
|
-
|
|
136
|
-
for (NSString *imageName in imageNames) {
|
|
137
|
-
[self.map.style removeImageForName:imageName];
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if ([self _hasNativeImages]) {
|
|
142
|
-
for (NSString *imageName in _nativeImages) {
|
|
143
|
-
[self.map.style removeImageForName:imageName];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
- (void)_addNativeImages:(NSArray<NSString *>*)nativeImages
|
|
149
|
-
{
|
|
150
|
-
if (!nativeImages) return;
|
|
151
|
-
|
|
152
|
-
for (NSString *imageName in nativeImages) {
|
|
153
|
-
// only add native images if they are not in the style yet (similar to [RCTMGLUtils fetchImages: style:])
|
|
154
|
-
if (![self.map.style imageForName:imageName]) {
|
|
155
|
-
UIImage *image = [UIImage imageNamed:imageName];
|
|
156
|
-
[self.map.style setImage:image forName:imageName];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
- (void)_addRemoteImages:(NSDictionary<NSString *, NSString *>*)remoteImages
|
|
162
|
-
{
|
|
163
|
-
if (!remoteImages) return;
|
|
164
|
-
NSDictionary<NSString *, NSString *> *missingImages = [NSMutableDictionary new];
|
|
165
|
-
|
|
166
|
-
// Add image placeholder for images that are not yet available in the style. This way
|
|
167
|
-
// we can load the images asynchronously and add the ShapeSource to the map without delay.
|
|
168
|
-
// The same is required when this ShapeSource is updated with new/added images and the
|
|
169
|
-
// data references them. In which case addMissingImageToStyle will take care of loading
|
|
170
|
-
// them in a similar way.
|
|
171
|
-
//
|
|
172
|
-
// See also: https://github.com/mapbox/mapbox-gl-native/pull/14253#issuecomment-478827792
|
|
173
|
-
for (NSString *imageName in remoteImages.allKeys) {
|
|
174
|
-
if (![self.map.style imageForName:imageName]) {
|
|
175
|
-
[self.map.style setImage:[RCTMGLImages placeholderImage] forName:imageName];
|
|
176
|
-
[missingImages setValue:_images[imageName] forKey:imageName];
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (missingImages.count > 0) {
|
|
181
|
-
// forceUpdate to ensure the placeholder images are updated
|
|
182
|
-
[RCTMGLUtils fetchImages:_bridge style:self.map.style objects:_images forceUpdate:true callback:^{ }];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
- (BOOL)_hasImages
|
|
187
|
-
{
|
|
188
|
-
return _images != nil && _images.count > 0;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
- (BOOL)_hasNativeImages
|
|
192
|
-
{
|
|
193
|
-
return _nativeImages != nil && _nativeImages.count > 0;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
@end
|
|
197
|
-
*/
|
|
@@ -63,6 +63,14 @@ class Logger {
|
|
|
63
63
|
static func log(level: LogLevel, message: String, error: Error) {
|
|
64
64
|
sharedInstance.log(level: level, message: "\(message) - error: \(error.localizedDescription) \(error)")
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
static func error(_ message: String) {
|
|
68
|
+
log(level: .error, message: message)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static func assert(_ message: String) {
|
|
72
|
+
log(level: .error, message: "Assertion failure: \(message)")
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
func logged<T>(_ msg: String, info: (() -> String)? = nil, level: Logger.LogLevel = .error, rejecter: RCTPromiseRejectBlock? = nil, fn : () throws -> T) -> T? {
|