@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.
Files changed (60) hide show
  1. package/.eslintrc.js +2 -1
  2. package/.github/workflows/ios-actions.yml +1 -1
  3. package/android/install.md +20 -1
  4. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +2 -0
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +22 -31
  6. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java +26 -0
  7. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphere.kt +59 -0
  8. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/atmosphere/RCTMGLAtmosphereManager.kt +30 -0
  9. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrain.kt +32 -27
  10. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/terrain/RCTMGLTerrainManager.kt +5 -11
  11. package/docs/Annotations.md +4 -3
  12. package/docs/Camera.md +1 -1
  13. package/docs/HeadingIndicator.md +1 -1
  14. package/docs/MapView.md +2 -2
  15. package/docs/SymbolLayer.md +4 -3
  16. package/docs/Terrain.md +64 -9
  17. package/docs/docs.json +66 -53
  18. package/index.d.ts +13 -80
  19. package/ios/RCTMGL-v10/RCTMGLCamera.swift +28 -26
  20. package/ios/RCTMGL-v10/RCTMGLImages.swift +1 -99
  21. package/ios/RCTMGL-v10/RCTMGLLogging.swift +8 -0
  22. package/ios/RCTMGL-v10/RCTMGLMapView.swift +35 -39
  23. package/ios/RCTMGL-v10/RCTMGLSingletonLayer.swift +7 -1
  24. package/ios/RCTMGL-v10/RCTMGLStyle.swift +34 -0
  25. package/ios/RCTMGL-v10/RCTMGLTerrain.swift +56 -63
  26. package/ios/RCTMGL-v10/RCTMGLTerrainManager.m +2 -3
  27. package/javascript/components/AbstractLayer.tsx +72 -0
  28. package/javascript/components/BackgroundLayer.js +1 -1
  29. package/javascript/components/Camera.tsx +17 -1
  30. package/javascript/components/CircleLayer.js +1 -1
  31. package/javascript/components/FillExtrusionLayer.js +1 -1
  32. package/javascript/components/FillLayer.js +1 -1
  33. package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +5 -6
  34. package/javascript/components/HeatmapLayer.js +1 -1
  35. package/javascript/components/LineLayer.js +1 -1
  36. package/javascript/components/MapView.js +8 -12
  37. package/javascript/components/RasterLayer.js +1 -1
  38. package/javascript/components/SkyLayer.js +1 -1
  39. package/javascript/components/SymbolLayer.tsx +113 -0
  40. package/javascript/components/Terrain.tsx +52 -0
  41. package/javascript/components/UserLocation.js +1 -1
  42. package/javascript/global.d.ts +4 -0
  43. package/javascript/index.js +8 -4
  44. package/javascript/types/index.ts +0 -14
  45. package/javascript/utils/MapboxStyles.ts +177 -52
  46. package/javascript/utils/StyleValue.ts +8 -6
  47. package/javascript/utils/deprecation.ts +39 -0
  48. package/javascript/utils/{filterUtils.js → filterUtils.tsx} +1 -1
  49. package/javascript/utils/styleMap.ts +26 -0
  50. package/package.json +6 -6
  51. package/scripts/autogenHelpers/DocJSONBuilder.js +2 -3
  52. package/scripts/autogenHelpers/globals.js +20 -7
  53. package/scripts/autogenerate.js +13 -0
  54. package/scripts/templates/MapboxStyles.ts.ejs +8 -3
  55. package/scripts/templates/RCTMGLStyleFactoryv10.java.ejs +1 -0
  56. package/.eslintignore +0 -1
  57. package/javascript/components/AbstractLayer.js +0 -46
  58. package/javascript/components/SymbolLayer.js +0 -120
  59. package/javascript/components/Terrain.js +0 -56
  60. package/javascript/utils/deprecation.js +0 -24
@@ -0,0 +1,113 @@
1
+ import React from 'react';
2
+ import { View, NativeModules, requireNativeComponent } from 'react-native';
3
+
4
+ import { type SymbolLayerStyleProps } from '../utils/MapboxStyles';
5
+ import { type StyleValue } from '../utils/StyleValue';
6
+
7
+ import AbstractLayer from './AbstractLayer';
8
+
9
+ const MapboxGL = NativeModules.MGLModule;
10
+
11
+ export const NATIVE_MODULE_NAME = 'RCTMGLSymbolLayer';
12
+
13
+ export type Props = {
14
+ /**
15
+ * A string that uniquely identifies the source in the style to which it is added.
16
+ */
17
+ id: string;
18
+
19
+ /**
20
+ * The source from which to obtain the data to style.
21
+ * If the source has not yet been added to the current style, the behavior is undefined.
22
+ * Inferred from parent source only if the layer is a direct child to it.
23
+ */
24
+ sourceID?: string;
25
+
26
+ /**
27
+ * Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
28
+ */
29
+ sourceLayerID?: string;
30
+
31
+ /**
32
+ * Inserts a layer above aboveLayerID.
33
+ */
34
+ aboveLayerID?: string;
35
+
36
+ /**
37
+ * Inserts a layer below belowLayerID
38
+ */
39
+ belowLayerID?: string;
40
+
41
+ /**
42
+ * Inserts a layer at a specified index
43
+ */
44
+ layerIndex?: number;
45
+
46
+ /**
47
+ * Filter only the features in the source layer that satisfy a condition that you define
48
+ */
49
+ filter?: string[];
50
+
51
+ /**
52
+ * The minimum zoom level at which the layer gets parsed and appears.
53
+ */
54
+ minZoomLevel?: number;
55
+
56
+ /**
57
+ * The maximum zoom level at which the layer gets parsed and appears.
58
+ */
59
+ maxZoomLevel?: number;
60
+
61
+ style: SymbolLayerStyleProps;
62
+
63
+ children?: JSX.Element | JSX.Element[];
64
+ };
65
+
66
+ type NativeTypeProps = Omit<Props, 'style'> & {
67
+ snapshot: boolean;
68
+ reactStyle?: { [key: string]: StyleValue };
69
+ };
70
+
71
+ const RCTMGLSymbolLayer =
72
+ requireNativeComponent<NativeTypeProps>(NATIVE_MODULE_NAME);
73
+
74
+ /**
75
+ * SymbolLayer is a style layer that renders icon and text labels at points or along lines on the map.
76
+ */
77
+ class SymbolLayer extends AbstractLayer<Props, NativeTypeProps> {
78
+ static defaultProps = {
79
+ sourceID: MapboxGL.StyleSource.DefaultSourceID,
80
+ };
81
+
82
+ _shouldSnapshot() {
83
+ let isSnapshot = false;
84
+
85
+ if (React.Children.count(this.props.children) <= 0) {
86
+ return isSnapshot;
87
+ }
88
+
89
+ React.Children.forEach(this.props.children, (child) => {
90
+ if (child?.type === View) {
91
+ isSnapshot = true;
92
+ }
93
+ });
94
+
95
+ return isSnapshot;
96
+ }
97
+
98
+ render() {
99
+ const props = {
100
+ ...this.baseProps,
101
+ snapshot: this._shouldSnapshot(),
102
+ sourceLayerID: this.props.sourceLayerID,
103
+ };
104
+
105
+ return (
106
+ <RCTMGLSymbolLayer ref={this.setNativeLayer} {...props}>
107
+ {this.props.children}
108
+ </RCTMGLSymbolLayer>
109
+ );
110
+ }
111
+ }
112
+
113
+ export default SymbolLayer;
@@ -0,0 +1,52 @@
1
+ import React, { memo, useMemo } from 'react';
2
+ import { HostComponent, requireNativeComponent } from 'react-native';
3
+
4
+ import type { TerrainLayerStyleProps, Value } from '../utils/MapboxStyles';
5
+ import { StyleValue, transformStyle } from '../utils/StyleValue';
6
+
7
+ export const NATIVE_MODULE_NAME = 'RCTMGLTerrain';
8
+
9
+ type Props = {
10
+ /**
11
+ * Name of a source of raster_dem type to be used for terrain elevation.
12
+ */
13
+ sourceID: string;
14
+
15
+ /**
16
+ * Deprecated, use exaggeration in style instead
17
+ */
18
+ exaggeration?: Value<number, ['zoom']>;
19
+
20
+ /**
21
+ * Customizable style attributes
22
+ */
23
+ style: TerrainLayerStyleProps;
24
+ };
25
+
26
+ export const Terrain = memo((props: Props) => {
27
+ let { style = {} } = props;
28
+
29
+ if (props.exaggeration) {
30
+ console.warn(
31
+ `Tarrain: exaggeration property is deprecated pls use style.exaggeration instead!`,
32
+ );
33
+ style = { exaggeration: props.exaggeration, ...style };
34
+ }
35
+
36
+ const baseProps = useMemo(() => {
37
+ return {
38
+ ...props,
39
+ reactStyle: transformStyle(style),
40
+ style: undefined,
41
+ };
42
+ }, [props, style]);
43
+ console.log('BASE PROPS', baseProps);
44
+
45
+ return <RCTMGLTerrain {...baseProps} />;
46
+ });
47
+
48
+ const RCTMGLTerrain: HostComponent<{
49
+ sourceID: string;
50
+ reactStyle?: { [key: string]: StyleValue };
51
+ style?: undefined;
52
+ }> = requireNativeComponent(NATIVE_MODULE_NAME);
@@ -49,7 +49,7 @@ export const normalIcon = (showsUserHeadingIndicator, heading) => [
49
49
  style={layerStyles.normal.foreground}
50
50
  />,
51
51
  ...(showsUserHeadingIndicator && heading !== null
52
- ? [HeadingIndicator(heading)]
52
+ ? [HeadingIndicator({ heading })]
53
53
  : []),
54
54
  ];
55
55
 
@@ -0,0 +1,4 @@
1
+ declare module '*.png' {
2
+ const value: import('react-native').ImageSourcePropType;
3
+ export default value;
4
+ }
@@ -1,6 +1,6 @@
1
1
  import { NativeModules } from 'react-native';
2
2
 
3
- import { Camera } from './components/Camera';
3
+ import { Camera, UserTrackingModes } from './components/Camera';
4
4
  import { Atmosphere } from './components/Atmosphere';
5
5
  import MapView from './components/MapView';
6
6
  import Light from './components/Light';
@@ -23,7 +23,7 @@ import SkyLayer from './components/SkyLayer';
23
23
  import SymbolLayer from './components/SymbolLayer';
24
24
  import RasterLayer from './components/RasterLayer';
25
25
  import BackgroundLayer from './components/BackgroundLayer';
26
- import Terrain from './components/Terrain';
26
+ import { Terrain } from './components/Terrain';
27
27
  import locationManager from './modules/location/locationManager';
28
28
  import offlineManager from './modules/offline/offlineManager';
29
29
  import snapshotManager from './modules/snapshot/snapshotManager';
@@ -38,13 +38,14 @@ import {
38
38
  } from './classes';
39
39
  import Style from './components/Style';
40
40
  import Logger from './utils/Logger';
41
+ import { deprecatedClass } from './utils/deprecation';
41
42
  import { requestAndroidLocationPermissions } from './requestAndroidLocationPermissions';
42
43
 
43
44
  const MapboxGL = { ...NativeModules.MGLModule };
44
45
 
45
46
  // static methods
46
47
  MapboxGL.requestAndroidLocationPermissions = requestAndroidLocationPermissions;
47
- MapboxGL.UserTrackingModes = Camera.UserTrackingModes;
48
+ MapboxGL.UserTrackingModes = UserTrackingModes;
48
49
 
49
50
  // components
50
51
  MapboxGL.MapView = MapView;
@@ -57,7 +58,10 @@ MapboxGL.Style = Style;
57
58
 
58
59
  // classes
59
60
  MapboxGL.AnimatedPoint = AnimatedPoint;
60
- MapboxGL.AnimatedMapPoint = AnimatedPoint; // For backwards compatibiilty.
61
+ MapboxGL.AnimatedMapPoint = deprecatedClass(
62
+ AnimatedPoint,
63
+ 'AnimatedMapPoint is deprecated please use AnimatedPoint',
64
+ );
61
65
  MapboxGL.AnimatedShape = AnimatedShape;
62
66
  MapboxGL.AnimatedCoordinatesArray = AnimatedCoordinatesArray;
63
67
  MapboxGL.AnimatedExtractCoordinateFromArray =
@@ -10,20 +10,6 @@ export type MapboxGLEvent<
10
10
  V = Element,
11
11
  > = SyntheticEvent<V, { type: T; payload: P }>;
12
12
 
13
- // Camera.
14
-
15
- export type UserTrackingMode = 'normal' | 'compass' | 'course';
16
-
17
- export type UserTrackingModeChangeCallback = (
18
- event: MapboxGLEvent<
19
- 'usertrackingmodechange',
20
- {
21
- followUserLocation: boolean;
22
- followUserMode: UserTrackingMode | null;
23
- }
24
- >,
25
- ) => void;
26
-
27
13
  // Animated.
28
14
 
29
15
  export interface AnimatedPoint extends GeoJsonObject {