@maplibre/maplibre-react-native 9.0.1 → 10.0.0-alpha.1

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 (146) hide show
  1. package/.eslintrc.js +10 -2
  2. package/.husky/pre-commit +5 -0
  3. package/.yarn/plugins/@yarnpkg/plugin-typescript.cjs +9 -0
  4. package/.yarn/sdks/eslint/bin/eslint.js +20 -0
  5. package/.yarn/sdks/eslint/lib/api.js +20 -0
  6. package/.yarn/sdks/eslint/package.json +6 -0
  7. package/.yarn/sdks/integrations.yml +5 -0
  8. package/.yarn/sdks/prettier/index.js +20 -0
  9. package/.yarn/sdks/prettier/package.json +6 -0
  10. package/.yarn/sdks/typescript/bin/tsc +20 -0
  11. package/.yarn/sdks/typescript/bin/tsserver +20 -0
  12. package/.yarn/sdks/typescript/lib/tsc.js +20 -0
  13. package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
  14. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
  15. package/.yarn/sdks/typescript/lib/typescript.js +20 -0
  16. package/.yarn/sdks/typescript/package.json +6 -0
  17. package/CHANGELOG.md +15 -1
  18. package/android/build.gradle +2 -2
  19. package/android/rctmgl/build.gradle +2 -4
  20. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.java +14 -0
  21. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSourceManager.java +26 -0
  22. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ClusterPropertyEntry.java +13 -0
  23. package/docs/Annotation.md +8 -9
  24. package/docs/BackgroundLayer.md +2 -10
  25. package/docs/Callout.md +5 -5
  26. package/docs/Camera.md +18 -47
  27. package/docs/CircleLayer.md +2 -10
  28. package/docs/FillExtrusionLayer.md +2 -10
  29. package/docs/FillLayer.md +2 -10
  30. package/docs/HeatmapLayer.md +2 -10
  31. package/docs/ImageSource.md +3 -2
  32. package/docs/Images.md +5 -3
  33. package/docs/Light.md +1 -1
  34. package/docs/LineLayer.md +2 -10
  35. package/docs/MapView.md +53 -37
  36. package/docs/MarkerView.md +4 -2
  37. package/docs/NativeUserLocation.md +2 -2
  38. package/docs/PointAnnotation.md +5 -8
  39. package/docs/RasterLayer.md +2 -10
  40. package/docs/RasterSource.md +3 -2
  41. package/docs/ShapeSource.md +12 -6
  42. package/docs/Style.md +1 -1
  43. package/docs/SymbolLayer.md +3 -10
  44. package/docs/UserLocation.md +8 -10
  45. package/docs/VectorSource.md +6 -5
  46. package/docs/coordinates.md +6 -0
  47. package/docs/docs.json +561 -1308
  48. package/docs/location.md +6 -0
  49. package/docs/snapshotManager.md +3 -3
  50. package/ios/RCTMGL/RCTMGLShapeSource.h +1 -0
  51. package/ios/RCTMGL/RCTMGLShapeSource.m +14 -0
  52. package/ios/RCTMGL/RCTMGLShapeSourceManager.m +1 -0
  53. package/ios/RCTMGL.xcodeproj/project.pbxproj +1 -0
  54. package/javascript/@types/assets.d.ts +4 -0
  55. package/javascript/MGLModule.ts +37 -0
  56. package/javascript/Maplibre.ts +65 -0
  57. package/javascript/components/AbstractLayer.tsx +107 -0
  58. package/javascript/components/AbstractSource.tsx +27 -0
  59. package/javascript/components/BackgroundLayer.tsx +43 -0
  60. package/javascript/components/{Callout.js → Callout.tsx} +67 -65
  61. package/javascript/components/{Camera.js → Camera.tsx} +266 -251
  62. package/javascript/components/CircleLayer.tsx +46 -0
  63. package/javascript/components/FillExtrusionLayer.tsx +47 -0
  64. package/javascript/components/FillLayer.tsx +41 -0
  65. package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +8 -8
  66. package/javascript/components/HeatmapLayer.tsx +44 -0
  67. package/javascript/components/ImageSource.tsx +78 -0
  68. package/javascript/components/Images.tsx +134 -0
  69. package/javascript/components/Light.tsx +67 -0
  70. package/javascript/components/LineLayer.tsx +42 -0
  71. package/javascript/components/{MapView.js → MapView.tsx} +365 -354
  72. package/javascript/components/MarkerView.tsx +104 -0
  73. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +44 -13
  74. package/javascript/components/NativeUserLocation.tsx +33 -0
  75. package/javascript/components/PointAnnotation.tsx +221 -0
  76. package/javascript/components/RasterLayer.tsx +41 -0
  77. package/javascript/components/RasterSource.tsx +117 -0
  78. package/javascript/components/ShapeSource.tsx +383 -0
  79. package/javascript/components/{Style.js → Style.tsx} +132 -38
  80. package/javascript/components/SymbolLayer.tsx +72 -0
  81. package/javascript/components/{UserLocation.js → UserLocation.tsx} +111 -110
  82. package/javascript/components/VectorSource.tsx +207 -0
  83. package/javascript/components/annotations/Annotation.tsx +134 -0
  84. package/javascript/index.ts +4 -0
  85. package/javascript/modules/location/{locationManager.js → locationManager.ts} +71 -10
  86. package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +20 -4
  87. package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +23 -7
  88. package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +81 -24
  89. package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +43 -6
  90. package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +5 -5
  91. package/javascript/requestAndroidLocationPermissions.ts +29 -0
  92. package/javascript/types/BaseProps.ts +5 -0
  93. package/javascript/types/OnPressEvent.ts +13 -0
  94. package/javascript/types/index.ts +7 -0
  95. package/javascript/utils/BridgeValue.ts +90 -0
  96. package/javascript/utils/{Logger.js → Logger.ts} +37 -18
  97. package/javascript/utils/MaplibreStyles.d.ts +1486 -0
  98. package/javascript/utils/StyleValue.ts +49 -0
  99. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +134 -0
  100. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +112 -0
  101. package/javascript/utils/animated/{AnimatedExtractCoordinateFromArray.js → AnimatedExtractCoordinateFromArray.ts} +5 -5
  102. package/javascript/utils/animated/{AnimatedPoint.js → AnimatedPoint.ts} +20 -12
  103. package/javascript/utils/animated/{AnimatedRouteCoordinatesArray.js → AnimatedRouteCoordinatesArray.ts} +39 -14
  104. package/javascript/utils/animated/{AnimatedShape.js → AnimatedShape.ts} +31 -10
  105. package/javascript/utils/{deprecation.js → deprecation.ts} +9 -6
  106. package/javascript/utils/filterUtils.ts +9 -0
  107. package/javascript/utils/geoUtils.ts +79 -0
  108. package/javascript/utils/{index.js → index.ts} +44 -24
  109. package/javascript/utils/styleMap.ts +264 -0
  110. package/package.json +43 -34
  111. package/plugin/build/withMapLibre.js +3 -2
  112. package/scripts/autogenHelpers/globals.js +1 -1
  113. package/scripts/autogenerate.js +14 -6
  114. package/scripts/templates/MaplibreStyles.ts.ejs +99 -0
  115. package/scripts/templates/index.d.ts.ejs +71 -42
  116. package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +3 -33
  117. package/setup-jest.js +3 -10
  118. package/tsconfig.json +20 -61
  119. package/index.d.ts +0 -954
  120. package/javascript/components/AbstractLayer.js +0 -75
  121. package/javascript/components/AbstractSource.js +0 -15
  122. package/javascript/components/BackgroundLayer.js +0 -97
  123. package/javascript/components/CircleLayer.js +0 -101
  124. package/javascript/components/FillExtrusionLayer.js +0 -98
  125. package/javascript/components/FillLayer.js +0 -94
  126. package/javascript/components/HeatmapLayer.js +0 -99
  127. package/javascript/components/ImageSource.js +0 -82
  128. package/javascript/components/Images.js +0 -119
  129. package/javascript/components/Light.js +0 -47
  130. package/javascript/components/LineLayer.js +0 -94
  131. package/javascript/components/MarkerView.js +0 -87
  132. package/javascript/components/NativeUserLocation.js +0 -41
  133. package/javascript/components/PointAnnotation.js +0 -216
  134. package/javascript/components/RasterLayer.js +0 -95
  135. package/javascript/components/RasterSource.js +0 -124
  136. package/javascript/components/ShapeSource.js +0 -357
  137. package/javascript/components/SymbolLayer.js +0 -120
  138. package/javascript/components/VectorSource.js +0 -200
  139. package/javascript/components/annotations/Annotation.js +0 -122
  140. package/javascript/index.js +0 -149
  141. package/javascript/utils/BridgeValue.js +0 -81
  142. package/javascript/utils/animated/AnimatedCoordinatesArray.js +0 -191
  143. package/javascript/utils/filterUtils.js +0 -7
  144. package/javascript/utils/geoUtils.js +0 -73
  145. package/javascript/utils/styleMap.js +0 -1932
  146. /package/javascript/utils/animated/{Animated.js → Animated.ts} +0 -0
@@ -1,75 +0,0 @@
1
- /* eslint react/prop-types:0 */
2
- import {getFilter} from '../utils/filterUtils';
3
- import {getStyleType} from '../utils/styleMap';
4
- import BridgeValue from '../utils/BridgeValue';
5
-
6
- import React from 'react';
7
- import {processColor} from 'react-native';
8
- import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
9
-
10
- class AbstractLayer extends React.PureComponent {
11
- get baseProps() {
12
- return {
13
- ...this.props,
14
- id: this.props.id,
15
- sourceID: this.props.sourceID,
16
- reactStyle: this.getStyle(),
17
- minZoomLevel: this.props.minZoomLevel,
18
- maxZoomLevel: this.props.maxZoomLevel,
19
- aboveLayerID: this.props.aboveLayerID,
20
- belowLayerID: this.props.belowLayerID,
21
- layerIndex: this.props.layerIndex,
22
- filter: getFilter(this.props.filter),
23
- style: undefined,
24
- };
25
- }
26
-
27
- getStyleTypeFormatter(styleType) {
28
- if (styleType === 'color') {
29
- return processColor;
30
- }
31
- }
32
-
33
- _getStyle(style) {
34
- if (!style) {
35
- return;
36
- }
37
-
38
- const nativeStyle = {};
39
- const styleProps = Object.keys(style);
40
- for (const styleProp of styleProps) {
41
- const styleType = getStyleType(styleProp);
42
- let rawStyle = style[styleProp];
43
-
44
- if (styleType === 'color' && typeof rawStyle === 'string') {
45
- rawStyle = processColor(rawStyle);
46
- } else if (styleType === 'image' && typeof rawStyle === 'number') {
47
- rawStyle = resolveAssetSource(rawStyle) || {};
48
- }
49
-
50
- const bridgeValue = new BridgeValue(rawStyle);
51
- nativeStyle[styleProp] = {
52
- styletype: styleType,
53
- stylevalue: bridgeValue.toJSON(),
54
- };
55
- }
56
-
57
- return nativeStyle;
58
- }
59
-
60
- getStyle() {
61
- return this._getStyle(this.props.style);
62
- }
63
-
64
- setNativeProps(props) {
65
- if (this.refs.nativeLayer) {
66
- let propsToPass = props;
67
- if (props.style) {
68
- propsToPass = {...props, reactStyle: this._getStyle(props.style)};
69
- }
70
- this.refs.nativeLayer.setNativeProps(propsToPass);
71
- }
72
- }
73
- }
74
-
75
- export default AbstractLayer;
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
-
3
- class AbstractSource extends React.PureComponent {
4
- setNativeProps(props) {
5
- if (this._nativeRef) {
6
- this._nativeRef.setNativeProps(props);
7
- } else {
8
- if (this.refs.nativeSource) {
9
- this.refs.nativeSource.setNativeProps(props);
10
- }
11
- }
12
- }
13
- }
14
-
15
- export default AbstractSource;
@@ -1,97 +0,0 @@
1
- import {viewPropTypes} from '../utils';
2
- import {BackgroundLayerStyleProp} from '../utils/styleMap';
3
-
4
- import AbstractLayer from './AbstractLayer';
5
-
6
- import PropTypes from 'prop-types';
7
- import React from 'react';
8
- import {NativeModules, requireNativeComponent} from 'react-native';
9
-
10
- const MapLibreGL = NativeModules.MGLModule;
11
-
12
- export const NATIVE_MODULE_NAME = 'RCTMGLBackgroundLayer';
13
-
14
- class BackgroundLayer extends AbstractLayer {
15
- static propTypes = {
16
- ...viewPropTypes,
17
-
18
- /**
19
- * A string that uniquely identifies the source in the style to which it is added.
20
- */
21
- id: PropTypes.string.isRequired,
22
-
23
- /**
24
- * The source from which to obtain the data to style.
25
- * If the source has not yet been added to the current style, the behavior is undefined.
26
- * Inferred from parent source only if the layer is a direct child to it.
27
- */
28
- sourceID: PropTypes.string,
29
-
30
- /**
31
- * Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
32
- */
33
- sourceLayerID: PropTypes.string,
34
-
35
- /**
36
- * Inserts a layer above aboveLayerID.
37
- */
38
- aboveLayerID: PropTypes.string,
39
-
40
- /**
41
- * Inserts a layer below belowLayerID
42
- */
43
- belowLayerID: PropTypes.string,
44
-
45
- /**
46
- * Inserts a layer at a specified index
47
- */
48
- layerIndex: PropTypes.number,
49
-
50
- /**
51
- * Filter only the features in the source layer that satisfy a condition that you define
52
- */
53
- filter: PropTypes.array,
54
-
55
- /**
56
- * The minimum zoom level at which the layer gets parsed and appears.
57
- */
58
- minZoomLevel: PropTypes.number,
59
-
60
- /**
61
- * The maximum zoom level at which the layer gets parsed and appears.
62
- */
63
- maxZoomLevel: PropTypes.number,
64
-
65
- /**
66
- * Customizable style attributes
67
- */
68
- style: PropTypes.oneOfType([
69
- BackgroundLayerStyleProp,
70
- PropTypes.arrayOf(BackgroundLayerStyleProp),
71
- ]),
72
- };
73
-
74
- static defaultProps = {
75
- sourceID: MapLibreGL.StyleSource.DefaultSourceID,
76
- };
77
-
78
- render() {
79
- return (
80
- <RCTMGLBackgroundLayer
81
- testID="rctmglBackgroundLayer"
82
- ref="nativeLayer"
83
- {...this.baseProps}
84
- />
85
- );
86
- }
87
- }
88
-
89
- const RCTMGLBackgroundLayer = requireNativeComponent(
90
- NATIVE_MODULE_NAME,
91
- BackgroundLayer,
92
- {
93
- nativeOnly: {reactStyle: true},
94
- },
95
- );
96
-
97
- export default BackgroundLayer;
@@ -1,101 +0,0 @@
1
- import {viewPropTypes} from '../utils';
2
- import {CircleLayerStyleProp} from '../utils/styleMap';
3
-
4
- import AbstractLayer from './AbstractLayer';
5
-
6
- import PropTypes from 'prop-types';
7
- import React from 'react';
8
- import {NativeModules, requireNativeComponent} from 'react-native';
9
-
10
- const MapLibreGL = NativeModules.MGLModule;
11
-
12
- export const NATIVE_MODULE_NAME = 'RCTMGLCircleLayer';
13
-
14
- /**
15
- * CircleLayer is a style layer that renders one or more filled circles on the map.
16
- */
17
- class CircleLayer extends AbstractLayer {
18
- static propTypes = {
19
- ...viewPropTypes,
20
-
21
- /**
22
- * A string that uniquely identifies the source in the style to which it is added.
23
- */
24
- id: PropTypes.string.isRequired,
25
-
26
- /**
27
- * The source from which to obtain the data to style.
28
- * If the source has not yet been added to the current style, the behavior is undefined.
29
- * Inferred from parent source only if the layer is a direct child to it.
30
- */
31
- sourceID: PropTypes.string,
32
-
33
- /**
34
- * Identifier of the layer within the source identified by the sourceID property
35
- * from which the receiver obtains the data to style.
36
- */
37
- sourceLayerID: PropTypes.string,
38
-
39
- /**
40
- * Inserts a layer above aboveLayerID.
41
- */
42
- aboveLayerID: PropTypes.string,
43
-
44
- /**
45
- * Inserts a layer below belowLayerID
46
- */
47
- belowLayerID: PropTypes.string,
48
-
49
- /**
50
- * Inserts a layer at a specified index
51
- */
52
- layerIndex: PropTypes.number,
53
-
54
- /**
55
- * Filter only the features in the source layer that satisfy a condition that you define
56
- */
57
- filter: PropTypes.array,
58
-
59
- /**
60
- * The minimum zoom level at which the layer gets parsed and appears.
61
- */
62
- minZoomLevel: PropTypes.number,
63
-
64
- /**
65
- * The maximum zoom level at which the layer gets parsed and appears.
66
- */
67
- maxZoomLevel: PropTypes.number,
68
-
69
- /**
70
- * Customizable style attributes
71
- */
72
- style: PropTypes.oneOfType([
73
- CircleLayerStyleProp,
74
- PropTypes.arrayOf(CircleLayerStyleProp),
75
- ]),
76
- };
77
-
78
- static defaultProps = {
79
- sourceID: MapLibreGL.StyleSource.DefaultSourceID,
80
- };
81
-
82
- render() {
83
- return (
84
- <RCTMGLCircleLayer
85
- testID="rctmglCircleLayer"
86
- ref="nativeLayer"
87
- {...this.baseProps}
88
- />
89
- );
90
- }
91
- }
92
-
93
- const RCTMGLCircleLayer = requireNativeComponent(
94
- NATIVE_MODULE_NAME,
95
- CircleLayer,
96
- {
97
- nativeOnly: {reactStyle: true},
98
- },
99
- );
100
-
101
- export default CircleLayer;
@@ -1,98 +0,0 @@
1
- import {viewPropTypes} from '../utils';
2
- import {FillExtrusionLayerStyleProp} from '../utils/styleMap';
3
-
4
- import AbstractLayer from './AbstractLayer';
5
-
6
- import PropTypes from 'prop-types';
7
- import React from 'react';
8
- import {NativeModules, requireNativeComponent} from 'react-native';
9
-
10
- const MapLibreGL = NativeModules.MGLModule;
11
-
12
- export const NATIVE_MODULE_NAME = 'RCTMGLFillExtrusionLayer';
13
-
14
- /**
15
- * FillExtrusionLayer is a style layer that renders one or more 3D extruded polygons on the map.
16
- */
17
- class FillExtrusionLayer extends AbstractLayer {
18
- static propTypes = {
19
- ...viewPropTypes,
20
-
21
- /**
22
- * A string that uniquely identifies the source in the style to which it is added.
23
- */
24
- id: PropTypes.string.isRequired,
25
-
26
- /**
27
- * The source from which to obtain the data to style.
28
- * If the source has not yet been added to the current style, the behavior is undefined.
29
- * Inferred from parent source only if the layer is a direct child to it.
30
- */
31
- sourceID: PropTypes.string,
32
-
33
- /**
34
- * Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
35
- */
36
- sourceLayerID: PropTypes.string,
37
-
38
- /**
39
- * Inserts a layer above aboveLayerID.
40
- */
41
- aboveLayerID: PropTypes.string,
42
-
43
- /**
44
- * Inserts a layer below belowLayerID
45
- */
46
- belowLayerID: PropTypes.string,
47
-
48
- /**
49
- * Inserts a layer at a specified index
50
- */
51
- layerIndex: PropTypes.number,
52
-
53
- /**
54
- * Filter only the features in the source layer that satisfy a condition that you define
55
- */
56
- filter: PropTypes.array,
57
-
58
- /**
59
- * The minimum zoom level at which the layer gets parsed and appears.
60
- */
61
- minZoomLevel: PropTypes.number,
62
-
63
- /**
64
- * The maximum zoom level at which the layer gets parsed and appears.
65
- */
66
- maxZoomLevel: PropTypes.number,
67
-
68
- /**
69
- * Customizable style attributes
70
- */
71
- style: PropTypes.oneOfType([
72
- FillExtrusionLayerStyleProp,
73
- PropTypes.arrayOf(FillExtrusionLayerStyleProp),
74
- ]),
75
- };
76
-
77
- static defaultProps = {
78
- sourceID: MapLibreGL.StyleSource.DefaultSourceID,
79
- };
80
-
81
- render() {
82
- const props = {
83
- ...this.baseProps,
84
- sourceLayerID: this.props.sourceLayerID,
85
- };
86
- return <RCTMGLFillExtrusionLayer ref="nativeLayer" {...props} />;
87
- }
88
- }
89
-
90
- const RCTMGLFillExtrusionLayer = requireNativeComponent(
91
- NATIVE_MODULE_NAME,
92
- FillExtrusionLayer,
93
- {
94
- nativeOnly: {reactStyle: true},
95
- },
96
- );
97
-
98
- export default FillExtrusionLayer;
@@ -1,94 +0,0 @@
1
- import {viewPropTypes} from '../utils';
2
- import {FillLayerStyleProp} from '../utils/styleMap';
3
-
4
- import AbstractLayer from './AbstractLayer';
5
-
6
- import PropTypes from 'prop-types';
7
- import React from 'react';
8
- import {NativeModules, requireNativeComponent} from 'react-native';
9
-
10
- const MapLibreGL = NativeModules.MGLModule;
11
-
12
- export const NATIVE_MODULE_NAME = 'RCTMGLFillLayer';
13
-
14
- /**
15
- * FillLayer is a style layer that renders one or more filled (and optionally stroked) polygons on the map.
16
- */
17
- class FillLayer extends AbstractLayer {
18
- static propTypes = {
19
- ...viewPropTypes,
20
-
21
- /**
22
- * A string that uniquely identifies the source in the style to which it is added.
23
- */
24
- id: PropTypes.string.isRequired,
25
-
26
- /**
27
- * The source from which to obtain the data to style.
28
- * If the source has not yet been added to the current style, the behavior is undefined.
29
- * Inferred from parent source only if the layer is a direct child to it.
30
- */
31
- sourceID: PropTypes.string,
32
-
33
- /**
34
- * Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
35
- */
36
- sourceLayerID: PropTypes.string,
37
-
38
- /**
39
- * Inserts a layer above aboveLayerID.
40
- */
41
- aboveLayerID: PropTypes.string,
42
-
43
- /**
44
- * Inserts a layer below belowLayerID
45
- */
46
- belowLayerID: PropTypes.string,
47
-
48
- /**
49
- * Inserts a layer at a specified index
50
- */
51
- layerIndex: PropTypes.number,
52
-
53
- /**
54
- * Filter only the features in the source layer that satisfy a condition that you define
55
- */
56
- filter: PropTypes.array,
57
-
58
- /**
59
- * The minimum zoom level at which the layer gets parsed and appears.
60
- */
61
- minZoomLevel: PropTypes.number,
62
-
63
- /**
64
- * The maximum zoom level at which the layer gets parsed and appears.
65
- */
66
- maxZoomLevel: PropTypes.number,
67
-
68
- /**
69
- * Customizable style attributes
70
- */
71
- style: PropTypes.oneOfType([
72
- FillLayerStyleProp,
73
- PropTypes.arrayOf(FillLayerStyleProp),
74
- ]),
75
- };
76
-
77
- static defaultProps = {
78
- sourceID: MapLibreGL.StyleSource.DefaultSourceID,
79
- };
80
-
81
- render() {
82
- const props = {
83
- ...this.baseProps,
84
- sourceLayerID: this.props.sourceLayerID,
85
- };
86
- return <RCTMGLFillLayer ref="nativeLayer" {...props} />;
87
- }
88
- }
89
-
90
- const RCTMGLFillLayer = requireNativeComponent(NATIVE_MODULE_NAME, FillLayer, {
91
- nativeOnly: {reactStyle: true},
92
- });
93
-
94
- export default FillLayer;
@@ -1,99 +0,0 @@
1
- import {viewPropTypes} from '../utils';
2
- import {HeatmapLayerStyleProp} from '../utils/styleMap';
3
-
4
- import AbstractLayer from './AbstractLayer';
5
-
6
- import PropTypes from 'prop-types';
7
- import React from 'react';
8
- import {NativeModules, requireNativeComponent} from 'react-native';
9
-
10
- const MapLibreGL = NativeModules.MGLModule;
11
-
12
- export const NATIVE_MODULE_NAME = 'RCTMGLHeatmapLayer';
13
-
14
- /**
15
- * HeatmapLayer is a style layer that renders one or more filled circles on the map.
16
- */
17
- class HeatmapLayer extends AbstractLayer {
18
- static propTypes = {
19
- ...viewPropTypes,
20
-
21
- /**
22
- * A string that uniquely identifies the source in the style to which it is added.
23
- */
24
- id: PropTypes.string.isRequired,
25
-
26
- /**
27
- * The source from which to obtain the data to style.
28
- * If the source has not yet been added to the current style, the behavior is undefined.
29
- * Inferred from parent source only if the layer is a direct child to it.
30
- */
31
- sourceID: PropTypes.string,
32
-
33
- /**
34
- * Identifier of the layer within the source identified by the sourceID property
35
- * from which the receiver obtains the data to style.
36
- */
37
- sourceLayerID: PropTypes.string,
38
-
39
- /**
40
- * Inserts a layer above aboveLayerID.
41
- */
42
- aboveLayerID: PropTypes.string,
43
-
44
- /**
45
- * Inserts a layer below belowLayerID
46
- */
47
- belowLayerID: PropTypes.string,
48
-
49
- /**
50
- * Inserts a layer at a specified index
51
- */
52
- layerIndex: PropTypes.number,
53
-
54
- /**
55
- * Filter only the features in the source layer that satisfy a condition that you define
56
- */
57
- filter: PropTypes.array,
58
-
59
- /**
60
- * The minimum zoom level at which the layer gets parsed and appears.
61
- */
62
- minZoomLevel: PropTypes.number,
63
-
64
- /**
65
- * The maximum zoom level at which the layer gets parsed and appears.
66
- */
67
- maxZoomLevel: PropTypes.number,
68
-
69
- /**
70
- * Customizable style attributes
71
- */
72
- style: PropTypes.oneOfType([
73
- HeatmapLayerStyleProp,
74
- PropTypes.arrayOf(HeatmapLayerStyleProp),
75
- ]),
76
- };
77
-
78
- static defaultProps = {
79
- sourceID: MapLibreGL.StyleSource.DefaultSourceID,
80
- };
81
-
82
- render() {
83
- const props = {
84
- ...this.baseProps,
85
- sourceLayerID: this.props.sourceLayerID,
86
- };
87
- return <RCTMGLHeatmapLayer ref="nativeLayer" {...props} />;
88
- }
89
- }
90
-
91
- const RCTMGLHeatmapLayer = requireNativeComponent(
92
- NATIVE_MODULE_NAME,
93
- HeatmapLayer,
94
- {
95
- nativeOnly: {reactStyle: true},
96
- },
97
- );
98
-
99
- export default HeatmapLayer;
@@ -1,82 +0,0 @@
1
- import {
2
- cloneReactChildrenWithProps,
3
- viewPropTypes,
4
- isNumber,
5
- resolveImagePath,
6
- } from '../utils';
7
-
8
- import AbstractSource from './AbstractSource';
9
-
10
- import PropTypes from 'prop-types';
11
- import {requireNativeComponent} from 'react-native';
12
- import React from 'react';
13
-
14
- export const NATIVE_MODULE_NAME = 'RCTMGLImageSource';
15
-
16
- /**
17
- * ImageSource is a content source that is used for a georeferenced raster image to be shown on the map.
18
- * The georeferenced image scales and rotates as the user zooms and rotates the map
19
- */
20
- class ImageSource extends AbstractSource {
21
- static propTypes = {
22
- ...viewPropTypes,
23
-
24
- /**
25
- * A string that uniquely identifies the source.
26
- */
27
- id: PropTypes.string.isRequired,
28
-
29
- /**
30
- * An HTTP(S) URL, absolute file URL, or local file URL to the source image.
31
- * Gifs are currently not supported.
32
- */
33
- url: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
34
-
35
- /**
36
- * The top left, top right, bottom right, and bottom left coordinates for the image.
37
- */
38
- coordinates: PropTypes.arrayOf(
39
- PropTypes.arrayOf(PropTypes.number).isRequired,
40
- ).isRequired,
41
- };
42
-
43
- _getURL() {
44
- let {url} = this.props;
45
-
46
- if (isNumber(this.props.url)) {
47
- url = resolveImagePath(this.props.url);
48
- }
49
-
50
- return url;
51
- }
52
-
53
- render() {
54
- if (
55
- !this.props.url ||
56
- !this.props.coordinates ||
57
- !this.props.coordinates.length
58
- ) {
59
- return null;
60
- }
61
-
62
- const props = {
63
- ...this.props,
64
- url: this._getURL(),
65
- };
66
-
67
- return (
68
- <RCTMGLImageSource ref="nativeSource" {...props}>
69
- {cloneReactChildrenWithProps(this.props.children, {
70
- sourceID: this.props.id,
71
- })}
72
- </RCTMGLImageSource>
73
- );
74
- }
75
- }
76
-
77
- const RCTMGLImageSource = requireNativeComponent(
78
- NATIVE_MODULE_NAME,
79
- ImageSource,
80
- );
81
-
82
- export default ImageSource;