@maplibre/maplibre-react-native 10.0.0-alpha.6 → 10.0.0-alpha.7
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 +3 -1
- package/.yarn/sdks/eslint/bin/eslint.js +8 -1
- package/.yarn/sdks/eslint/lib/api.js +8 -1
- package/.yarn/sdks/eslint/lib/unsupported-api.js +8 -1
- package/.yarn/sdks/prettier/bin/prettier.cjs +8 -1
- package/.yarn/sdks/prettier/index.cjs +8 -1
- package/.yarn/sdks/typescript/bin/tsc +8 -1
- package/.yarn/sdks/typescript/bin/tsserver +8 -1
- package/.yarn/sdks/typescript/lib/tsc.js +8 -1
- package/.yarn/sdks/typescript/lib/tsserver.js +20 -6
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +20 -6
- package/.yarn/sdks/typescript/lib/typescript.js +8 -1
- package/CHANGELOG.md +4 -0
- package/CONTRIBUTING.md +10 -9
- package/docs/Camera.md +3 -3
- package/docs/MapView.md +9 -33
- package/docs/UserLocation.md +10 -2
- package/docs/docs.json +16 -31
- package/javascript/Maplibre.ts +5 -1
- package/javascript/components/BackgroundLayer.tsx +27 -20
- package/javascript/components/Callout.tsx +40 -40
- package/javascript/components/Camera.tsx +421 -478
- package/javascript/components/CircleLayer.tsx +29 -22
- package/javascript/components/FillExtrusionLayer.tsx +23 -23
- package/javascript/components/FillLayer.tsx +22 -19
- package/javascript/components/HeatmapLayer.tsx +21 -19
- package/javascript/components/ImageSource.tsx +25 -32
- package/javascript/components/Images.tsx +36 -35
- package/javascript/components/Light.tsx +20 -47
- package/javascript/components/LineLayer.tsx +23 -20
- package/javascript/components/MapView.tsx +604 -554
- package/javascript/components/MarkerView.tsx +23 -38
- package/javascript/components/NativeUserLocation.tsx +3 -5
- package/javascript/components/PointAnnotation.tsx +111 -87
- package/javascript/components/RasterLayer.tsx +21 -18
- package/javascript/components/RasterSource.tsx +39 -42
- package/javascript/components/ShapeSource.tsx +287 -239
- package/javascript/components/Style.tsx +1 -1
- package/javascript/components/SymbolLayer.tsx +34 -28
- package/javascript/components/UserLocation.tsx +164 -151
- package/javascript/components/VectorSource.tsx +128 -117
- package/javascript/components/annotations/Annotation.tsx +105 -79
- package/javascript/{components/AbstractLayer.tsx → hooks/useAbstractLayer.ts} +54 -37
- package/javascript/hooks/useAbstractSource.ts +34 -0
- package/javascript/hooks/useNativeBridge.ts +125 -0
- package/javascript/hooks/useNativeRef.ts +13 -0
- package/javascript/hooks/useOnce.ts +12 -0
- package/javascript/utils/Logger.ts +3 -3
- package/package.json +2 -1
- package/javascript/components/AbstractSource.tsx +0 -27
- package/javascript/components/NativeBridgeComponent.tsx +0 -117
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {CircleLayerStyleProps} from '../utils/MaplibreStyles';
|
|
2
2
|
import BaseProps from '../types/BaseProps';
|
|
3
|
+
import useAbstractLayer, {
|
|
4
|
+
BaseLayerProps,
|
|
5
|
+
NativeBaseProps,
|
|
6
|
+
} from '../hooks/useAbstractLayer';
|
|
3
7
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import React, {ReactElement} from 'react';
|
|
8
|
+
import React from 'react';
|
|
7
9
|
import {NativeModules, requireNativeComponent} from 'react-native';
|
|
8
10
|
|
|
9
11
|
const MapLibreGL = NativeModules.MLNModule;
|
|
10
12
|
|
|
11
13
|
export const NATIVE_MODULE_NAME = 'RCTMLNCircleLayer';
|
|
12
14
|
|
|
13
|
-
interface CircleLayerProps extends BaseProps, BaseLayerProps {
|
|
15
|
+
export interface CircleLayerProps extends BaseProps, BaseLayerProps {
|
|
14
16
|
/**
|
|
15
17
|
* Customizable style attributes
|
|
16
18
|
*/
|
|
@@ -21,26 +23,31 @@ interface NativeProps
|
|
|
21
23
|
extends Omit<CircleLayerProps, 'style'>,
|
|
22
24
|
NativeBaseProps {}
|
|
23
25
|
|
|
26
|
+
const RCTMLNCircleLayer =
|
|
27
|
+
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
28
|
+
|
|
24
29
|
/**
|
|
25
30
|
* CircleLayer is a style layer that renders one or more filled circles on the map.
|
|
26
31
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
const CircleLayer: React.FC<CircleLayerProps> = ({
|
|
33
|
+
sourceID = MapLibreGL.StyleSource.DefaultSourceID,
|
|
34
|
+
...props
|
|
35
|
+
}: CircleLayerProps) => {
|
|
36
|
+
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
37
|
+
CircleLayerProps,
|
|
38
|
+
NativeProps
|
|
39
|
+
>({
|
|
40
|
+
...props,
|
|
41
|
+
sourceID,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<RCTMLNCircleLayer
|
|
46
|
+
testID="rctmlnCircleLayer"
|
|
47
|
+
ref={setNativeLayer}
|
|
48
|
+
{...baseProps}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
45
52
|
|
|
46
53
|
export default CircleLayer;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {FillExtrusionLayerStyleProps} from '../utils/MaplibreStyles';
|
|
2
2
|
import BaseProps from '../types/BaseProps';
|
|
3
|
+
import useAbstractLayer, {
|
|
4
|
+
BaseLayerProps,
|
|
5
|
+
NativeBaseProps,
|
|
6
|
+
} from '../hooks/useAbstractLayer';
|
|
3
7
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import React, {ReactElement} from 'react';
|
|
8
|
+
import React from 'react';
|
|
7
9
|
import {NativeModules, requireNativeComponent} from 'react-native';
|
|
8
10
|
|
|
9
11
|
const MapLibreGL = NativeModules.MLNModule;
|
|
10
12
|
|
|
11
13
|
export const NATIVE_MODULE_NAME = 'RCTMLNFillExtrusionLayer';
|
|
12
14
|
|
|
13
|
-
interface FillExtrusionLayerProps extends BaseProps, BaseLayerProps {
|
|
15
|
+
export interface FillExtrusionLayerProps extends BaseProps, BaseLayerProps {
|
|
14
16
|
/**
|
|
15
17
|
* Customizable style attributes
|
|
16
18
|
*/
|
|
@@ -21,27 +23,25 @@ interface NativeProps
|
|
|
21
23
|
extends Omit<FillExtrusionLayerProps, 'style'>,
|
|
22
24
|
NativeBaseProps {}
|
|
23
25
|
|
|
26
|
+
const RCTMLNFillExtrusionLayer =
|
|
27
|
+
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
28
|
+
|
|
24
29
|
/**
|
|
25
30
|
* FillExtrusionLayer is a style layer that renders one or more 3D extruded polygons on the map.
|
|
26
31
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const RCTMLNFillExtrusionLayer =
|
|
45
|
-
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
32
|
+
const FillExtrusionLayer: React.FC<FillExtrusionLayerProps> = ({
|
|
33
|
+
sourceID = MapLibreGL.StyleSource.DefaultSourceID,
|
|
34
|
+
...props
|
|
35
|
+
}: FillExtrusionLayerProps) => {
|
|
36
|
+
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
37
|
+
FillExtrusionLayerProps,
|
|
38
|
+
NativeProps
|
|
39
|
+
>({
|
|
40
|
+
...props,
|
|
41
|
+
sourceID,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return <RCTMLNFillExtrusionLayer ref={setNativeLayer} {...baseProps} />;
|
|
45
|
+
};
|
|
46
46
|
|
|
47
47
|
export default FillExtrusionLayer;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {FillLayerStyleProps} from '../utils/MaplibreStyles';
|
|
2
2
|
import BaseProps from '../types/BaseProps';
|
|
3
|
+
import useAbstractLayer, {
|
|
4
|
+
BaseLayerProps,
|
|
5
|
+
NativeBaseProps,
|
|
6
|
+
} from '../hooks/useAbstractLayer';
|
|
3
7
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import React, {ReactElement} from 'react';
|
|
8
|
+
import React from 'react';
|
|
7
9
|
import {NativeModules, requireNativeComponent} from 'react-native';
|
|
8
10
|
|
|
9
11
|
const MapLibreGL = NativeModules.MLNModule;
|
|
10
12
|
|
|
11
13
|
export const NATIVE_MODULE_NAME = 'RCTMLNFillLayer';
|
|
12
14
|
|
|
13
|
-
interface FillLayerProps extends BaseProps, BaseLayerProps {
|
|
15
|
+
export interface FillLayerProps extends BaseProps, BaseLayerProps {
|
|
14
16
|
/**
|
|
15
17
|
* Customizable style attributes
|
|
16
18
|
*/
|
|
@@ -19,23 +21,24 @@ interface FillLayerProps extends BaseProps, BaseLayerProps {
|
|
|
19
21
|
|
|
20
22
|
interface NativeProps extends Omit<FillLayerProps, 'style'>, NativeBaseProps {}
|
|
21
23
|
|
|
24
|
+
const RCTMLNFillLayer = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
25
|
+
|
|
22
26
|
/**
|
|
23
27
|
* FillLayer is a style layer that renders one or more filled (and optionally stroked) polygons on the map.
|
|
24
28
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const RCTMLNFillLayer = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
29
|
+
const FillLayer: React.FC<FillLayerProps> = ({
|
|
30
|
+
sourceID = MapLibreGL.StyleSource.DefaultSourceID,
|
|
31
|
+
...props
|
|
32
|
+
}: FillLayerProps) => {
|
|
33
|
+
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
34
|
+
FillLayerProps,
|
|
35
|
+
NativeProps
|
|
36
|
+
>({
|
|
37
|
+
...props,
|
|
38
|
+
sourceID,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return <RCTMLNFillLayer ref={setNativeLayer} {...baseProps} />;
|
|
42
|
+
};
|
|
40
43
|
|
|
41
44
|
export default FillLayer;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {HeatmapLayerStyleProps} from '../utils/MaplibreStyles';
|
|
2
2
|
import BaseProps from '../types/BaseProps';
|
|
3
|
+
import useAbstractLayer, {
|
|
4
|
+
BaseLayerProps,
|
|
5
|
+
NativeBaseProps,
|
|
6
|
+
} from '../hooks/useAbstractLayer';
|
|
3
7
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import React, {ReactElement} from 'react';
|
|
8
|
+
import React from 'react';
|
|
7
9
|
import {NativeModules, requireNativeComponent} from 'react-native';
|
|
8
10
|
|
|
9
11
|
const MapLibreGL = NativeModules.MLNModule;
|
|
@@ -21,24 +23,24 @@ interface NativeProps
|
|
|
21
23
|
extends Omit<HeatmapLayerProps, 'style'>,
|
|
22
24
|
NativeBaseProps {}
|
|
23
25
|
|
|
26
|
+
const RCTMLNHeatmapLayer =
|
|
27
|
+
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
24
28
|
/**
|
|
25
29
|
* HeatmapLayer is a style layer that renders one or more filled circles on the map.
|
|
26
30
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const RCTMLNHeatmapLayer =
|
|
42
|
-
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
31
|
+
const HeatmapLayer: React.FC<HeatmapLayerProps> = ({
|
|
32
|
+
sourceID = MapLibreGL.StyleSource.DefaultSourceID,
|
|
33
|
+
...props
|
|
34
|
+
}: HeatmapLayerProps) => {
|
|
35
|
+
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
36
|
+
HeatmapLayerProps,
|
|
37
|
+
NativeProps
|
|
38
|
+
>({
|
|
39
|
+
...props,
|
|
40
|
+
sourceID,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return <RCTMLNHeatmapLayer ref={setNativeLayer} {...baseProps} />;
|
|
44
|
+
};
|
|
43
45
|
|
|
44
46
|
export default HeatmapLayer;
|
|
@@ -4,15 +4,14 @@ import {
|
|
|
4
4
|
resolveImagePath,
|
|
5
5
|
} from '../utils';
|
|
6
6
|
import BaseProps from '../types/BaseProps';
|
|
7
|
-
|
|
8
|
-
import AbstractSource from './AbstractSource';
|
|
7
|
+
import useAbstractSource from '../hooks/useAbstractSource';
|
|
9
8
|
|
|
10
9
|
import {requireNativeComponent} from 'react-native';
|
|
11
10
|
import React, {ReactElement} from 'react';
|
|
12
11
|
|
|
13
12
|
export const NATIVE_MODULE_NAME = 'RCTMLNImageSource';
|
|
14
13
|
|
|
15
|
-
interface ImageSourceProps extends BaseProps {
|
|
14
|
+
export interface ImageSourceProps extends BaseProps {
|
|
16
15
|
/**
|
|
17
16
|
* A string that uniquely identifies the source.
|
|
18
17
|
*/
|
|
@@ -37,42 +36,36 @@ interface ImageSourceProps extends BaseProps {
|
|
|
37
36
|
|
|
38
37
|
type NativeProps = ImageSourceProps;
|
|
39
38
|
|
|
39
|
+
const RCTMLNImageSource =
|
|
40
|
+
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
41
|
+
|
|
40
42
|
/**
|
|
41
43
|
* ImageSource is a content source that is used for a georeferenced raster image to be shown on the map.
|
|
42
44
|
* The georeferenced image scales and rotates as the user zooms and rotates the map
|
|
43
45
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return isNumber(this.props.url)
|
|
47
|
-
? resolveImagePath(this.props.url)
|
|
48
|
-
: this.props.url;
|
|
49
|
-
}
|
|
46
|
+
const ImageSource: React.FC<ImageSourceProps> = (props: ImageSourceProps) => {
|
|
47
|
+
const {setNativeRef} = useAbstractSource<NativeProps>();
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
!this.props.coordinates ||
|
|
55
|
-
!this.props.coordinates.length
|
|
56
|
-
) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
49
|
+
const _getURL = (): string | undefined => {
|
|
50
|
+
return isNumber(props.url) ? resolveImagePath(props.url) : props.url;
|
|
51
|
+
};
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
url: this._getURL(),
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<RCTMLNImageSource ref={this.setNativeRef} {...props}>
|
|
67
|
-
{cloneReactChildrenWithProps(this.props.children, {
|
|
68
|
-
sourceID: this.props.id,
|
|
69
|
-
})}
|
|
70
|
-
</RCTMLNImageSource>
|
|
71
|
-
);
|
|
53
|
+
if (!props.url || !props.coordinates || !props.coordinates.length) {
|
|
54
|
+
return null;
|
|
72
55
|
}
|
|
73
|
-
}
|
|
74
56
|
|
|
75
|
-
const
|
|
76
|
-
|
|
57
|
+
const allProps = {
|
|
58
|
+
...props,
|
|
59
|
+
url: _getURL(),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<RCTMLNImageSource ref={setNativeRef} {...allProps}>
|
|
64
|
+
{cloneReactChildrenWithProps(allProps.children, {
|
|
65
|
+
sourceID: allProps.id,
|
|
66
|
+
})}
|
|
67
|
+
</RCTMLNImageSource>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
77
70
|
|
|
78
71
|
export default ImageSource;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseProps from '../types/BaseProps';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import {SHAPE_SOURCE_NATIVE_ASSETS_KEY} from './ShapeSource';
|
|
4
4
|
|
|
5
5
|
import React, {ReactElement} from 'react';
|
|
6
6
|
import {
|
|
@@ -54,7 +54,6 @@ interface ImagesProps extends BaseProps {
|
|
|
54
54
|
* any of the `Images` component of the Map.
|
|
55
55
|
*/
|
|
56
56
|
onImageMissing?(imageKey: string): void;
|
|
57
|
-
|
|
58
57
|
id?: string;
|
|
59
58
|
children: ReactElement;
|
|
60
59
|
}
|
|
@@ -62,72 +61,74 @@ interface ImagesProps extends BaseProps {
|
|
|
62
61
|
/**
|
|
63
62
|
* Images defines the images used in Symbol etc layers
|
|
64
63
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
const Images = ({
|
|
65
|
+
images,
|
|
66
|
+
nativeAssetImages,
|
|
67
|
+
onImageMissing,
|
|
68
|
+
id,
|
|
69
|
+
children,
|
|
70
|
+
}: ImagesProps): ReactElement => {
|
|
71
|
+
const _getImages = (): {
|
|
69
72
|
images?: {[key: string]: ImageEntry};
|
|
70
73
|
nativeImages?: ImageEntry[];
|
|
71
|
-
} {
|
|
72
|
-
if (!
|
|
74
|
+
} => {
|
|
75
|
+
if (!images && !nativeAssetImages) {
|
|
73
76
|
return {};
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
const
|
|
79
|
+
const imagesResult: {[key: string]: ImageEntry} = {};
|
|
77
80
|
let nativeImages: ImageEntry[] = [];
|
|
78
81
|
|
|
79
|
-
if (
|
|
80
|
-
const imageNames = Object.keys(
|
|
82
|
+
if (images) {
|
|
83
|
+
const imageNames = Object.keys(images);
|
|
81
84
|
for (const imageName of imageNames) {
|
|
82
|
-
const value =
|
|
85
|
+
const value = images[imageName];
|
|
83
86
|
if (
|
|
84
|
-
imageName ===
|
|
87
|
+
imageName === SHAPE_SOURCE_NATIVE_ASSETS_KEY &&
|
|
85
88
|
Array.isArray(value)
|
|
86
89
|
) {
|
|
87
90
|
console.warn(
|
|
88
|
-
`Use of ${
|
|
91
|
+
`Use of ${SHAPE_SOURCE_NATIVE_ASSETS_KEY} in Images#images is deprecated please use Images#nativeAssetImages`,
|
|
89
92
|
);
|
|
90
93
|
nativeImages = value;
|
|
91
94
|
} else if (_isUrlOrPath(value)) {
|
|
92
|
-
|
|
95
|
+
imagesResult[imageName] = value;
|
|
93
96
|
} else if (_isImageSourcePropType(value)) {
|
|
94
97
|
const res = Image.resolveAssetSource(value);
|
|
95
98
|
if (res && res.uri) {
|
|
96
|
-
|
|
99
|
+
imagesResult[imageName] = res;
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
if (
|
|
103
|
-
nativeImages =
|
|
105
|
+
if (nativeAssetImages) {
|
|
106
|
+
nativeImages = nativeAssetImages;
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
return {
|
|
107
|
-
images,
|
|
110
|
+
images: imagesResult,
|
|
108
111
|
nativeImages,
|
|
109
112
|
};
|
|
110
|
-
}
|
|
113
|
+
};
|
|
111
114
|
|
|
112
|
-
_onImageMissing(
|
|
115
|
+
const _onImageMissing = (
|
|
113
116
|
event: NativeSyntheticEvent<{payload: {imageKey: string}}>,
|
|
114
|
-
): void {
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
+
): void => {
|
|
118
|
+
if (onImageMissing) {
|
|
119
|
+
onImageMissing(event.nativeEvent.payload.imageKey);
|
|
117
120
|
}
|
|
118
|
-
}
|
|
121
|
+
};
|
|
119
122
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
123
|
+
const props = {
|
|
124
|
+
id,
|
|
125
|
+
hasOnImageMissing: !!onImageMissing,
|
|
126
|
+
onImageMissing: _onImageMissing,
|
|
127
|
+
..._getImages(),
|
|
128
|
+
};
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
130
|
+
return <RCTMLNImages {...props}>{children}</RCTMLNImages>;
|
|
131
|
+
};
|
|
131
132
|
|
|
132
133
|
const RCTMLNImages = requireNativeComponent(NATIVE_MODULE_NAME);
|
|
133
134
|
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import {LightLayerStyleProps} from '../utils/MaplibreStyles';
|
|
2
2
|
import BaseProps from '../types/BaseProps';
|
|
3
|
-
import {StyleValue
|
|
3
|
+
import {StyleValue} from '../utils/StyleValue';
|
|
4
|
+
import {BaseLayerProps} from '../hooks/useAbstractLayer';
|
|
5
|
+
import useAbstractLayer from '../hooks/useAbstractLayer';
|
|
4
6
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import React, {
|
|
8
|
-
Component,
|
|
9
|
-
createRef,
|
|
10
|
-
MutableRefObject,
|
|
11
|
-
ReactElement,
|
|
12
|
-
} from 'react';
|
|
13
|
-
import {NativeMethods, requireNativeComponent} from 'react-native';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import {requireNativeComponent} from 'react-native';
|
|
14
9
|
|
|
15
10
|
export const NATIVE_MODULE_NAME = 'RCTMLNLight';
|
|
16
11
|
|
|
17
|
-
interface LightProps extends BaseProps {
|
|
12
|
+
interface LightProps extends BaseProps, BaseLayerProps {
|
|
18
13
|
/**
|
|
19
14
|
* Customizable style attributes
|
|
20
15
|
*/
|
|
@@ -24,44 +19,22 @@ interface LightProps extends BaseProps {
|
|
|
24
19
|
interface NativeProps extends Omit<LightProps, 'style'> {
|
|
25
20
|
reactStyle?: {[key: string]: StyleValue};
|
|
26
21
|
}
|
|
22
|
+
|
|
23
|
+
const RCTMLNLight = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
24
|
+
|
|
27
25
|
/**
|
|
28
26
|
* Light represents the light source for extruded geometries
|
|
29
27
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
<RCTMLNLight
|
|
56
|
-
ref={this.lightRef}
|
|
57
|
-
testID="rctmlnLight"
|
|
58
|
-
{...this.props}
|
|
59
|
-
reactStyle={this.getStyle()}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const RCTMLNLight = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
28
|
+
const Light: React.FC<LightProps> = (props: LightProps) => {
|
|
29
|
+
const {baseProps, setNativeLayer} = useAbstractLayer<LightProps, NativeProps>(
|
|
30
|
+
{
|
|
31
|
+
...props,
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<RCTMLNLight ref={setNativeLayer} testID="rctmlnLight" {...baseProps} />
|
|
37
|
+
);
|
|
38
|
+
};
|
|
66
39
|
|
|
67
40
|
export default Light;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {LineLayerStyleProps} from '../utils/MaplibreStyles';
|
|
2
2
|
import BaseProps from '../types/BaseProps';
|
|
3
|
+
import useAbstractLayer, {
|
|
4
|
+
BaseLayerProps,
|
|
5
|
+
NativeBaseProps,
|
|
6
|
+
} from '../hooks/useAbstractLayer';
|
|
3
7
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import React, {ReactElement} from 'react';
|
|
8
|
+
import React from 'react';
|
|
7
9
|
import {NativeModules, requireNativeComponent} from 'react-native';
|
|
8
10
|
|
|
9
11
|
const MapLibreGL = NativeModules.MLNModule;
|
|
10
12
|
|
|
11
13
|
export const NATIVE_MODULE_NAME = 'RCTMLNLineLayer';
|
|
12
14
|
|
|
13
|
-
interface LineLayerProps extends BaseProps, BaseLayerProps {
|
|
15
|
+
export interface LineLayerProps extends BaseProps, BaseLayerProps {
|
|
14
16
|
/**
|
|
15
17
|
* Customizable style attributes
|
|
16
18
|
*/
|
|
@@ -19,24 +21,25 @@ interface LineLayerProps extends BaseProps, BaseLayerProps {
|
|
|
19
21
|
|
|
20
22
|
interface NativeProps extends Omit<LineLayerProps, 'style'>, NativeBaseProps {}
|
|
21
23
|
|
|
24
|
+
const RCTMLNLineLayer =
|
|
25
|
+
requireNativeComponent<NativeBaseProps>(NATIVE_MODULE_NAME);
|
|
26
|
+
|
|
22
27
|
/**
|
|
23
28
|
* LineLayer is a style layer that renders one or more stroked polylines on the map.
|
|
24
29
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const RCTMLNLineLayer =
|
|
40
|
-
requireNativeComponent<NativeBaseProps>(NATIVE_MODULE_NAME);
|
|
30
|
+
const LineLayer: React.FC<LineLayerProps> = ({
|
|
31
|
+
sourceID = MapLibreGL.StyleSource.DefaultSourceID,
|
|
32
|
+
...props
|
|
33
|
+
}: LineLayerProps) => {
|
|
34
|
+
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
35
|
+
LineLayerProps,
|
|
36
|
+
NativeProps
|
|
37
|
+
>({
|
|
38
|
+
...props,
|
|
39
|
+
sourceID,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return <RCTMLNLineLayer ref={setNativeLayer} {...baseProps} />;
|
|
43
|
+
};
|
|
41
44
|
|
|
42
45
|
export default LineLayer;
|