@maplibre/maplibre-react-native 9.1.0 → 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 (137) 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 +11 -0
  18. package/docs/Annotation.md +8 -9
  19. package/docs/BackgroundLayer.md +2 -10
  20. package/docs/Callout.md +5 -5
  21. package/docs/Camera.md +18 -47
  22. package/docs/CircleLayer.md +2 -10
  23. package/docs/FillExtrusionLayer.md +2 -10
  24. package/docs/FillLayer.md +2 -10
  25. package/docs/HeatmapLayer.md +2 -10
  26. package/docs/ImageSource.md +3 -2
  27. package/docs/Images.md +5 -3
  28. package/docs/Light.md +1 -1
  29. package/docs/LineLayer.md +2 -10
  30. package/docs/MapView.md +53 -37
  31. package/docs/MarkerView.md +4 -2
  32. package/docs/NativeUserLocation.md +2 -2
  33. package/docs/PointAnnotation.md +5 -8
  34. package/docs/RasterLayer.md +2 -10
  35. package/docs/RasterSource.md +3 -2
  36. package/docs/ShapeSource.md +12 -7
  37. package/docs/Style.md +1 -1
  38. package/docs/SymbolLayer.md +3 -10
  39. package/docs/UserLocation.md +8 -10
  40. package/docs/VectorSource.md +6 -5
  41. package/docs/coordinates.md +6 -0
  42. package/docs/docs.json +518 -1272
  43. package/docs/location.md +6 -0
  44. package/docs/snapshotManager.md +3 -3
  45. package/javascript/@types/assets.d.ts +4 -0
  46. package/javascript/MGLModule.ts +37 -0
  47. package/javascript/Maplibre.ts +65 -0
  48. package/javascript/components/AbstractLayer.tsx +107 -0
  49. package/javascript/components/AbstractSource.tsx +27 -0
  50. package/javascript/components/BackgroundLayer.tsx +43 -0
  51. package/javascript/components/{Callout.js → Callout.tsx} +67 -65
  52. package/javascript/components/{Camera.js → Camera.tsx} +266 -251
  53. package/javascript/components/CircleLayer.tsx +46 -0
  54. package/javascript/components/FillExtrusionLayer.tsx +47 -0
  55. package/javascript/components/FillLayer.tsx +41 -0
  56. package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +8 -8
  57. package/javascript/components/HeatmapLayer.tsx +44 -0
  58. package/javascript/components/ImageSource.tsx +78 -0
  59. package/javascript/components/Images.tsx +134 -0
  60. package/javascript/components/Light.tsx +67 -0
  61. package/javascript/components/LineLayer.tsx +42 -0
  62. package/javascript/components/{MapView.js → MapView.tsx} +365 -354
  63. package/javascript/components/MarkerView.tsx +104 -0
  64. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +44 -13
  65. package/javascript/components/NativeUserLocation.tsx +33 -0
  66. package/javascript/components/PointAnnotation.tsx +221 -0
  67. package/javascript/components/RasterLayer.tsx +41 -0
  68. package/javascript/components/RasterSource.tsx +117 -0
  69. package/javascript/components/ShapeSource.tsx +383 -0
  70. package/javascript/components/{Style.js → Style.tsx} +129 -38
  71. package/javascript/components/SymbolLayer.tsx +72 -0
  72. package/javascript/components/{UserLocation.js → UserLocation.tsx} +111 -110
  73. package/javascript/components/VectorSource.tsx +207 -0
  74. package/javascript/components/annotations/Annotation.tsx +134 -0
  75. package/javascript/index.ts +4 -0
  76. package/javascript/modules/location/{locationManager.js → locationManager.ts} +71 -10
  77. package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +20 -4
  78. package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +23 -7
  79. package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +81 -24
  80. package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +43 -6
  81. package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +5 -5
  82. package/javascript/requestAndroidLocationPermissions.ts +29 -0
  83. package/javascript/types/BaseProps.ts +5 -0
  84. package/javascript/types/OnPressEvent.ts +13 -0
  85. package/javascript/types/index.ts +7 -0
  86. package/javascript/utils/BridgeValue.ts +90 -0
  87. package/javascript/utils/{Logger.js → Logger.ts} +37 -18
  88. package/javascript/utils/MaplibreStyles.d.ts +1486 -0
  89. package/javascript/utils/StyleValue.ts +49 -0
  90. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +134 -0
  91. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +112 -0
  92. package/javascript/utils/animated/{AnimatedExtractCoordinateFromArray.js → AnimatedExtractCoordinateFromArray.ts} +5 -5
  93. package/javascript/utils/animated/{AnimatedPoint.js → AnimatedPoint.ts} +20 -12
  94. package/javascript/utils/animated/{AnimatedRouteCoordinatesArray.js → AnimatedRouteCoordinatesArray.ts} +39 -14
  95. package/javascript/utils/animated/{AnimatedShape.js → AnimatedShape.ts} +31 -10
  96. package/javascript/utils/{deprecation.js → deprecation.ts} +9 -6
  97. package/javascript/utils/filterUtils.ts +9 -0
  98. package/javascript/utils/geoUtils.ts +79 -0
  99. package/javascript/utils/{index.js → index.ts} +44 -24
  100. package/javascript/utils/styleMap.ts +264 -0
  101. package/package.json +35 -27
  102. package/plugin/build/withMapLibre.js +3 -2
  103. package/scripts/autogenHelpers/globals.js +1 -1
  104. package/scripts/autogenerate.js +14 -6
  105. package/scripts/templates/MaplibreStyles.ts.ejs +99 -0
  106. package/scripts/templates/index.d.ts.ejs +71 -42
  107. package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +3 -33
  108. package/setup-jest.js +1 -10
  109. package/tsconfig.json +20 -61
  110. package/index.d.ts +0 -955
  111. package/javascript/components/AbstractLayer.js +0 -75
  112. package/javascript/components/AbstractSource.js +0 -15
  113. package/javascript/components/BackgroundLayer.js +0 -97
  114. package/javascript/components/CircleLayer.js +0 -101
  115. package/javascript/components/FillExtrusionLayer.js +0 -98
  116. package/javascript/components/FillLayer.js +0 -94
  117. package/javascript/components/HeatmapLayer.js +0 -99
  118. package/javascript/components/ImageSource.js +0 -82
  119. package/javascript/components/Images.js +0 -119
  120. package/javascript/components/Light.js +0 -47
  121. package/javascript/components/LineLayer.js +0 -94
  122. package/javascript/components/MarkerView.js +0 -87
  123. package/javascript/components/NativeUserLocation.js +0 -41
  124. package/javascript/components/PointAnnotation.js +0 -216
  125. package/javascript/components/RasterLayer.js +0 -95
  126. package/javascript/components/RasterSource.js +0 -124
  127. package/javascript/components/ShapeSource.js +0 -372
  128. package/javascript/components/SymbolLayer.js +0 -120
  129. package/javascript/components/VectorSource.js +0 -200
  130. package/javascript/components/annotations/Annotation.js +0 -122
  131. package/javascript/index.js +0 -149
  132. package/javascript/utils/BridgeValue.js +0 -81
  133. package/javascript/utils/animated/AnimatedCoordinatesArray.js +0 -191
  134. package/javascript/utils/filterUtils.js +0 -7
  135. package/javascript/utils/geoUtils.js +0 -73
  136. package/javascript/utils/styleMap.js +0 -1932
  137. /package/javascript/utils/animated/{Animated.js → Animated.ts} +0 -0
@@ -0,0 +1,46 @@
1
+ import {CircleLayerStyleProps} from '../utils/MaplibreStyles';
2
+ import BaseProps from '../types/BaseProps';
3
+
4
+ import AbstractLayer, {BaseLayerProps, NativeBaseProps} from './AbstractLayer';
5
+
6
+ import React, {ReactElement} from 'react';
7
+ import {NativeModules, requireNativeComponent} from 'react-native';
8
+
9
+ const MapLibreGL = NativeModules.MGLModule;
10
+
11
+ export const NATIVE_MODULE_NAME = 'RCTMGLCircleLayer';
12
+
13
+ interface CircleLayerProps extends BaseProps, BaseLayerProps {
14
+ /**
15
+ * Customizable style attributes
16
+ */
17
+ style?: CircleLayerStyleProps;
18
+ }
19
+
20
+ interface NativeProps
21
+ extends Omit<CircleLayerProps, 'style'>,
22
+ NativeBaseProps {}
23
+
24
+ /**
25
+ * CircleLayer is a style layer that renders one or more filled circles on the map.
26
+ */
27
+ class CircleLayer extends AbstractLayer<CircleLayerProps, NativeProps> {
28
+ static defaultProps = {
29
+ sourceID: MapLibreGL.StyleSource.DefaultSourceID,
30
+ };
31
+
32
+ render(): ReactElement {
33
+ return (
34
+ <RCTMGLCircleLayer
35
+ testID="rctmglCircleLayer"
36
+ ref={this.setNativeLayer}
37
+ {...this.baseProps}
38
+ />
39
+ );
40
+ }
41
+ }
42
+
43
+ const RCTMGLCircleLayer =
44
+ requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
45
+
46
+ export default CircleLayer;
@@ -0,0 +1,47 @@
1
+ import {FillExtrusionLayerStyleProps} from '../utils/MaplibreStyles';
2
+ import BaseProps from '../types/BaseProps';
3
+
4
+ import AbstractLayer, {BaseLayerProps, NativeBaseProps} from './AbstractLayer';
5
+
6
+ import React, {ReactElement} from 'react';
7
+ import {NativeModules, requireNativeComponent} from 'react-native';
8
+
9
+ const MapLibreGL = NativeModules.MGLModule;
10
+
11
+ export const NATIVE_MODULE_NAME = 'RCTMGLFillExtrusionLayer';
12
+
13
+ interface FillExtrusionLayerProps extends BaseProps, BaseLayerProps {
14
+ /**
15
+ * Customizable style attributes
16
+ */
17
+ style?: FillExtrusionLayerStyleProps;
18
+ }
19
+
20
+ interface NativeProps
21
+ extends Omit<FillExtrusionLayerProps, 'style'>,
22
+ NativeBaseProps {}
23
+
24
+ /**
25
+ * FillExtrusionLayer is a style layer that renders one or more 3D extruded polygons on the map.
26
+ */
27
+ class FillExtrusionLayer extends AbstractLayer<
28
+ FillExtrusionLayerProps,
29
+ NativeProps
30
+ > {
31
+ static defaultProps = {
32
+ sourceID: MapLibreGL.StyleSource.DefaultSourceID,
33
+ };
34
+
35
+ render(): ReactElement {
36
+ const props = {
37
+ ...this.baseProps,
38
+ sourceLayerID: this.props.sourceLayerID,
39
+ };
40
+ return <RCTMGLFillExtrusionLayer ref={this.setNativeLayer} {...props} />;
41
+ }
42
+ }
43
+
44
+ const RCTMGLFillExtrusionLayer =
45
+ requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
46
+
47
+ export default FillExtrusionLayer;
@@ -0,0 +1,41 @@
1
+ import {FillLayerStyleProps} from '../utils/MaplibreStyles';
2
+ import BaseProps from '../types/BaseProps';
3
+
4
+ import AbstractLayer, {BaseLayerProps, NativeBaseProps} from './AbstractLayer';
5
+
6
+ import React, {ReactElement} from 'react';
7
+ import {NativeModules, requireNativeComponent} from 'react-native';
8
+
9
+ const MapLibreGL = NativeModules.MGLModule;
10
+
11
+ export const NATIVE_MODULE_NAME = 'RCTMGLFillLayer';
12
+
13
+ interface FillLayerProps extends BaseProps, BaseLayerProps {
14
+ /**
15
+ * Customizable style attributes
16
+ */
17
+ style?: FillLayerStyleProps;
18
+ }
19
+
20
+ interface NativeProps extends Omit<FillLayerProps, 'style'>, NativeBaseProps {}
21
+
22
+ /**
23
+ * FillLayer is a style layer that renders one or more filled (and optionally stroked) polygons on the map.
24
+ */
25
+ class FillLayer extends AbstractLayer<FillLayerProps, NativeProps> {
26
+ static defaultProps = {
27
+ sourceID: MapLibreGL.StyleSource.DefaultSourceID,
28
+ };
29
+
30
+ render(): ReactElement {
31
+ const props = {
32
+ ...this.baseProps,
33
+ sourceLayerID: this.props.sourceLayerID,
34
+ };
35
+ return <RCTMGLFillLayer ref={this.setNativeLayer} {...props} />;
36
+ }
37
+ }
38
+
39
+ const RCTMGLFillLayer = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
40
+
41
+ export default FillLayer;
@@ -1,18 +1,22 @@
1
+ import BaseProps from '../types/BaseProps';
1
2
  import headingIcon from '../../assets/heading.png';
2
3
 
3
4
  import SymbolLayer from './SymbolLayer';
4
5
 
5
- import PropTypes from 'prop-types';
6
- import React from 'react';
6
+ import React, {ReactElement} from 'react';
7
7
 
8
8
  const style = {
9
9
  iconImage: headingIcon,
10
10
  iconAllowOverlap: true,
11
11
  iconPitchAlignment: 'map',
12
12
  iconRotationAlignment: 'map',
13
- };
13
+ } as const;
14
14
 
15
- const HeadingIndicator = heading => (
15
+ interface HeadingIndicatorProps extends BaseProps {
16
+ heading?: number;
17
+ }
18
+
19
+ const HeadingIndicator = ({heading}: HeadingIndicatorProps): ReactElement => (
16
20
  <SymbolLayer
17
21
  key="mapboxUserLocationHeadingIndicator"
18
22
  id="mapboxUserLocationHeadingIndicator"
@@ -24,8 +28,4 @@ const HeadingIndicator = heading => (
24
28
  />
25
29
  );
26
30
 
27
- HeadingIndicator.propTypes = {
28
- heading: PropTypes.number,
29
- };
30
-
31
31
  export default HeadingIndicator;
@@ -0,0 +1,44 @@
1
+ import {HeatmapLayerStyleProps} from '../utils/MaplibreStyles';
2
+ import BaseProps from '../types/BaseProps';
3
+
4
+ import AbstractLayer, {BaseLayerProps, NativeBaseProps} from './AbstractLayer';
5
+
6
+ import React, {ReactElement} from 'react';
7
+ import {NativeModules, requireNativeComponent} from 'react-native';
8
+
9
+ const MapLibreGL = NativeModules.MGLModule;
10
+
11
+ export const NATIVE_MODULE_NAME = 'RCTMGLHeatmapLayer';
12
+
13
+ interface HeatmapLayerProps extends BaseProps, BaseLayerProps {
14
+ /**
15
+ * Customizable style attributes
16
+ */
17
+ style?: HeatmapLayerStyleProps;
18
+ }
19
+
20
+ interface NativeProps
21
+ extends Omit<HeatmapLayerProps, 'style'>,
22
+ NativeBaseProps {}
23
+
24
+ /**
25
+ * HeatmapLayer is a style layer that renders one or more filled circles on the map.
26
+ */
27
+ class HeatmapLayer extends AbstractLayer<HeatmapLayerProps, NativeProps> {
28
+ static defaultProps = {
29
+ sourceID: MapLibreGL.StyleSource.DefaultSourceID,
30
+ };
31
+
32
+ render(): ReactElement {
33
+ const props = {
34
+ ...this.baseProps,
35
+ sourceLayerID: this.props.sourceLayerID,
36
+ };
37
+ return <RCTMGLHeatmapLayer ref={this.setNativeLayer} {...props} />;
38
+ }
39
+ }
40
+
41
+ const RCTMGLHeatmapLayer =
42
+ requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
43
+
44
+ export default HeatmapLayer;
@@ -0,0 +1,78 @@
1
+ import {
2
+ cloneReactChildrenWithProps,
3
+ isNumber,
4
+ resolveImagePath,
5
+ } from '../utils';
6
+ import BaseProps from '../types/BaseProps';
7
+
8
+ import AbstractSource from './AbstractSource';
9
+
10
+ import {requireNativeComponent} from 'react-native';
11
+ import React, {ReactElement} from 'react';
12
+
13
+ export const NATIVE_MODULE_NAME = 'RCTMGLImageSource';
14
+
15
+ interface ImageSourceProps extends BaseProps {
16
+ /**
17
+ * A string that uniquely identifies the source.
18
+ */
19
+ id: string;
20
+ /**
21
+ * An HTTP(S) URL, absolute file URL, or local file URL to the source image.
22
+ * Gifs are currently not supported.
23
+ */
24
+ url?: number | string;
25
+ /**
26
+ * The top left, top right, bottom right, and bottom left coordinates for the image.
27
+ */
28
+ coordinates?: [
29
+ GeoJSON.Position,
30
+ GeoJSON.Position,
31
+ GeoJSON.Position,
32
+ GeoJSON.Position,
33
+ ];
34
+
35
+ children?: ReactElement | ReactElement[];
36
+ }
37
+
38
+ type NativeProps = ImageSourceProps;
39
+
40
+ /**
41
+ * ImageSource is a content source that is used for a georeferenced raster image to be shown on the map.
42
+ * The georeferenced image scales and rotates as the user zooms and rotates the map
43
+ */
44
+ class ImageSource extends AbstractSource<ImageSourceProps, NativeProps> {
45
+ _getURL(): string | undefined {
46
+ return isNumber(this.props.url)
47
+ ? resolveImagePath(this.props.url)
48
+ : this.props.url;
49
+ }
50
+
51
+ render(): ReactElement | null {
52
+ if (
53
+ !this.props.url ||
54
+ !this.props.coordinates ||
55
+ !this.props.coordinates.length
56
+ ) {
57
+ return null;
58
+ }
59
+
60
+ const props = {
61
+ ...this.props,
62
+ url: this._getURL(),
63
+ };
64
+
65
+ return (
66
+ <RCTMGLImageSource ref={this.setNativeRef} {...props}>
67
+ {cloneReactChildrenWithProps(this.props.children, {
68
+ sourceID: this.props.id,
69
+ })}
70
+ </RCTMGLImageSource>
71
+ );
72
+ }
73
+ }
74
+
75
+ const RCTMGLImageSource =
76
+ requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
77
+
78
+ export default ImageSource;
@@ -0,0 +1,134 @@
1
+ import BaseProps from '../types/BaseProps';
2
+
3
+ import ShapeSource from './ShapeSource';
4
+
5
+ import React, {ReactElement} from 'react';
6
+ import {
7
+ requireNativeComponent,
8
+ Image,
9
+ NativeSyntheticEvent,
10
+ ImageSourcePropType,
11
+ ImageURISource,
12
+ } from 'react-native';
13
+
14
+ export const NATIVE_MODULE_NAME = 'RCTMGLImages';
15
+
16
+ export type ImageEntry = string | ImageSourcePropType;
17
+
18
+ function _isUrlOrPath(value: ImageEntry): boolean {
19
+ return (
20
+ (typeof value === 'string' || value instanceof String) &&
21
+ (value.startsWith('file://') ||
22
+ value.startsWith('http://') ||
23
+ value.startsWith('https://') ||
24
+ value.startsWith('data:') ||
25
+ value.startsWith('asset://') ||
26
+ value.startsWith('/'))
27
+ );
28
+ }
29
+
30
+ function _isImageSourcePropType(
31
+ value: ImageEntry,
32
+ ): value is ImageSourcePropType {
33
+ if (typeof value === 'number' || value instanceof Number) {
34
+ return true;
35
+ }
36
+ const valueAsSource = value as ImageURISource;
37
+ return !!valueAsSource.uri && typeof valueAsSource.uri === 'string';
38
+ }
39
+
40
+ interface ImagesProps extends BaseProps {
41
+ /**
42
+ * Specifies the external images in key-value pairs required for the shape source.
43
+ * Keys are names - see iconImage expressions, values can be either urls-s objects
44
+ * with format {uri: 'http://...'}` or `require('image.png')` or `import 'image.png'`
45
+ */
46
+ images?: {[key: string]: ImageEntry};
47
+ /**
48
+ * If you have an asset under Image.xcassets on iOS and the drawables directory on android
49
+ * you can specify an array of string names with assets as the key `['pin']`.
50
+ */
51
+ nativeAssetImages?: string[];
52
+ /**
53
+ * Gets called when a Layer is trying to render an image whose key is not present in
54
+ * any of the `Images` component of the Map.
55
+ */
56
+ onImageMissing?(imageKey: string): void;
57
+
58
+ id?: string;
59
+ children: ReactElement;
60
+ }
61
+
62
+ /**
63
+ * Images defines the images used in Symbol etc layers
64
+ */
65
+ class Images extends React.Component<ImagesProps> {
66
+ static NATIVE_ASSETS_KEY = 'assets';
67
+
68
+ _getImages(): {
69
+ images?: {[key: string]: ImageEntry};
70
+ nativeImages?: ImageEntry[];
71
+ } {
72
+ if (!this.props.images && !this.props.nativeAssetImages) {
73
+ return {};
74
+ }
75
+
76
+ const images: {[key: string]: ImageEntry} = {};
77
+ let nativeImages: ImageEntry[] = [];
78
+
79
+ if (this.props.images) {
80
+ const imageNames = Object.keys(this.props.images);
81
+ for (const imageName of imageNames) {
82
+ const value = this.props.images[imageName];
83
+ if (
84
+ imageName === ShapeSource.NATIVE_ASSETS_KEY &&
85
+ Array.isArray(value)
86
+ ) {
87
+ console.warn(
88
+ `Use of ${ShapeSource.NATIVE_ASSETS_KEY} in Images#images is deprecated please use Images#nativeAssetImages`,
89
+ );
90
+ nativeImages = value;
91
+ } else if (_isUrlOrPath(value)) {
92
+ images[imageName] = value;
93
+ } else if (_isImageSourcePropType(value)) {
94
+ const res = Image.resolveAssetSource(value);
95
+ if (res && res.uri) {
96
+ images[imageName] = res;
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ if (this.props.nativeAssetImages) {
103
+ nativeImages = this.props.nativeAssetImages;
104
+ }
105
+
106
+ return {
107
+ images,
108
+ nativeImages,
109
+ };
110
+ }
111
+
112
+ _onImageMissing(
113
+ event: NativeSyntheticEvent<{payload: {imageKey: string}}>,
114
+ ): void {
115
+ if (this.props.onImageMissing) {
116
+ this.props.onImageMissing(event.nativeEvent.payload.imageKey);
117
+ }
118
+ }
119
+
120
+ render(): ReactElement {
121
+ const props = {
122
+ id: this.props.id,
123
+ hasOnImageMissing: !!this.props.onImageMissing,
124
+ onImageMissing: this._onImageMissing.bind(this),
125
+ ...this._getImages(),
126
+ };
127
+
128
+ return <RCTMGLImages {...props}>{this.props.children}</RCTMGLImages>;
129
+ }
130
+ }
131
+
132
+ const RCTMGLImages = requireNativeComponent(NATIVE_MODULE_NAME);
133
+
134
+ export default Images;
@@ -0,0 +1,67 @@
1
+ import {LightLayerStyleProps} from '../utils/MaplibreStyles';
2
+ import BaseProps from '../types/BaseProps';
3
+ import {StyleValue, transformStyle} from '../utils/StyleValue';
4
+
5
+ import AbstractLayer, {BaseLayerProps} from './AbstractLayer';
6
+
7
+ import React, {
8
+ Component,
9
+ createRef,
10
+ MutableRefObject,
11
+ ReactElement,
12
+ } from 'react';
13
+ import {NativeMethods, requireNativeComponent} from 'react-native';
14
+
15
+ export const NATIVE_MODULE_NAME = 'RCTMGLLight';
16
+
17
+ interface LightProps extends BaseProps {
18
+ /**
19
+ * Customizable style attributes
20
+ */
21
+ style?: LightLayerStyleProps;
22
+ }
23
+
24
+ interface NativeProps extends Omit<LightProps, 'style'> {
25
+ reactStyle?: {[key: string]: StyleValue};
26
+ }
27
+ /**
28
+ * Light represents the light source for extruded geometries
29
+ */
30
+ class Light extends AbstractLayer<LightProps, NativeProps> {
31
+ lightRef: MutableRefObject<
32
+ (Component<NativeProps> & Readonly<NativeMethods>) | null
33
+ >;
34
+
35
+ constructor(props: LightProps & BaseLayerProps) {
36
+ super(props);
37
+
38
+ this.lightRef = createRef<
39
+ (Component<NativeProps> & Readonly<NativeMethods>) | null
40
+ >();
41
+ }
42
+
43
+ setNativeProps(props: LightProps): void {
44
+ if (this.lightRef.current && props.style) {
45
+ const nativeProps = {
46
+ ...props,
47
+ reactStyle: transformStyle(props.style),
48
+ };
49
+ this.lightRef.current.setNativeProps(nativeProps);
50
+ }
51
+ }
52
+
53
+ render(): ReactElement {
54
+ return (
55
+ <RCTMGLLight
56
+ ref={this.lightRef}
57
+ testID="rctmglLight"
58
+ {...this.props}
59
+ reactStyle={this.getStyle()}
60
+ />
61
+ );
62
+ }
63
+ }
64
+
65
+ const RCTMGLLight = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
66
+
67
+ export default Light;
@@ -0,0 +1,42 @@
1
+ import {LineLayerStyleProps} from '../utils/MaplibreStyles';
2
+ import BaseProps from '../types/BaseProps';
3
+
4
+ import AbstractLayer, {BaseLayerProps, NativeBaseProps} from './AbstractLayer';
5
+
6
+ import React, {ReactElement} from 'react';
7
+ import {NativeModules, requireNativeComponent} from 'react-native';
8
+
9
+ const MapLibreGL = NativeModules.MGLModule;
10
+
11
+ export const NATIVE_MODULE_NAME = 'RCTMGLLineLayer';
12
+
13
+ interface LineLayerProps extends BaseProps, BaseLayerProps {
14
+ /**
15
+ * Customizable style attributes
16
+ */
17
+ style?: LineLayerStyleProps;
18
+ }
19
+
20
+ interface NativeProps extends Omit<LineLayerProps, 'style'>, NativeBaseProps {}
21
+
22
+ /**
23
+ * LineLayer is a style layer that renders one or more stroked polylines on the map.
24
+ */
25
+ class LineLayer extends AbstractLayer<LineLayerProps, NativeProps> {
26
+ static defaultProps = {
27
+ sourceID: MapLibreGL.StyleSource.DefaultSourceID,
28
+ };
29
+
30
+ render(): ReactElement {
31
+ const props = {
32
+ ...this.baseProps,
33
+ sourceLayerID: this.props.sourceLayerID,
34
+ };
35
+ return <RCTMGLLineLayer ref={this.setNativeLayer} {...props} />;
36
+ }
37
+ }
38
+
39
+ const RCTMGLLineLayer =
40
+ requireNativeComponent<NativeBaseProps>(NATIVE_MODULE_NAME);
41
+
42
+ export default LineLayer;