@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
package/javascript/Maplibre.ts
CHANGED
|
@@ -5,10 +5,12 @@ export {
|
|
|
5
5
|
type CameraPadding,
|
|
6
6
|
type CameraAnimationMode,
|
|
7
7
|
type CameraBounds,
|
|
8
|
+
type CameraRef,
|
|
8
9
|
} from './components/Camera';
|
|
9
|
-
export {default as MapView, type
|
|
10
|
+
export {default as MapView, type MapViewRef} from './components/MapView';
|
|
10
11
|
export {default as Light} from './components/Light';
|
|
11
12
|
export {default as PointAnnotation} from './components/PointAnnotation';
|
|
13
|
+
export type {PointAnnotationRef} from './components/PointAnnotation';
|
|
12
14
|
export {default as Annotation} from './components/annotations/Annotation';
|
|
13
15
|
export {default as Callout} from './components/Callout';
|
|
14
16
|
export {requestAndroidLocationPermissions} from './requestAndroidLocationPermissions';
|
|
@@ -16,8 +18,10 @@ export {
|
|
|
16
18
|
default as UserLocation,
|
|
17
19
|
UserLocationRenderMode,
|
|
18
20
|
} from './components/UserLocation';
|
|
21
|
+
export type {UserLocationRef} from './components/UserLocation';
|
|
19
22
|
export {default as VectorSource} from './components/VectorSource';
|
|
20
23
|
export {default as ShapeSource} from './components/ShapeSource';
|
|
24
|
+
export type {ShapeSourceRef} from './components/ShapeSource';
|
|
21
25
|
export {default as RasterSource} from './components/RasterSource';
|
|
22
26
|
export {default as ImageSource} from './components/ImageSource';
|
|
23
27
|
export {default as Images} from './components/Images';
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {BackgroundLayerStyleProps} 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, {ReactNode} 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 = 'RCTMLNBackgroundLayer';
|
|
12
14
|
|
|
13
|
-
interface BackgroundLayerProps extends BaseProps, BaseLayerProps {
|
|
15
|
+
export interface BackgroundLayerProps extends BaseProps, BaseLayerProps {
|
|
14
16
|
/**
|
|
15
17
|
* Customizable style attributes
|
|
16
18
|
*/
|
|
@@ -21,23 +23,28 @@ interface NativeProps
|
|
|
21
23
|
extends Omit<BackgroundLayerProps, 'style'>,
|
|
22
24
|
NativeBaseProps {}
|
|
23
25
|
|
|
24
|
-
class BackgroundLayer extends AbstractLayer<BackgroundLayerProps, NativeProps> {
|
|
25
|
-
static defaultProps = {
|
|
26
|
-
sourceID: MapLibreGL.StyleSource.DefaultSourceID,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
render(): ReactNode {
|
|
30
|
-
return (
|
|
31
|
-
<RCTMLNBackgroundLayer
|
|
32
|
-
testID="rctmlnBackgroundLayer"
|
|
33
|
-
ref={this.setNativeLayer}
|
|
34
|
-
{...this.baseProps}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
26
|
const RCTMLNBackgroundLayer =
|
|
41
27
|
requireNativeComponent<BackgroundLayerProps>(NATIVE_MODULE_NAME);
|
|
42
28
|
|
|
29
|
+
const BackgroundLayer: React.FC<BackgroundLayerProps> = ({
|
|
30
|
+
sourceID = MapLibreGL.StyleSource.DefaultSourceID,
|
|
31
|
+
...props
|
|
32
|
+
}: BackgroundLayerProps) => {
|
|
33
|
+
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
34
|
+
BackgroundLayerProps,
|
|
35
|
+
NativeProps
|
|
36
|
+
>({
|
|
37
|
+
...props,
|
|
38
|
+
sourceID,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<RCTMLNBackgroundLayer
|
|
43
|
+
testID="rctmlnBackgroundLayer"
|
|
44
|
+
ref={setNativeLayer}
|
|
45
|
+
{...baseProps}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
43
50
|
export default BackgroundLayer;
|
|
@@ -82,59 +82,59 @@ interface NativeProps extends Omit<CalloutProps, 'style'> {
|
|
|
82
82
|
/**
|
|
83
83
|
* Callout that displays information about a selected annotation near the annotation.
|
|
84
84
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
const Callout = (props: CalloutProps): ReactElement => {
|
|
86
|
+
const {
|
|
87
|
+
title,
|
|
88
|
+
style,
|
|
89
|
+
containerStyle,
|
|
90
|
+
contentStyle,
|
|
91
|
+
tipStyle,
|
|
92
|
+
textStyle,
|
|
93
|
+
children,
|
|
94
|
+
} = props;
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const _containerStyle: ViewStyle[] = [
|
|
97
|
+
{
|
|
98
|
+
position: 'absolute',
|
|
99
|
+
zIndex: 999,
|
|
100
|
+
backgroundColor: 'transparent',
|
|
101
|
+
...containerStyle,
|
|
102
|
+
} as ViewStyle,
|
|
103
|
+
];
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
}
|
|
105
|
+
const _hasChildren = React.Children.count(children) > 0;
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
return React.Children.count(this.props.children) > 0;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
_renderDefaultCallout(): ReactElement {
|
|
107
|
+
const _renderDefaultCallout = (): ReactElement => {
|
|
107
108
|
return (
|
|
108
|
-
<Animated.View style={[styles.container,
|
|
109
|
-
<View style={[styles.content,
|
|
110
|
-
<Text style={[styles.title,
|
|
111
|
-
{
|
|
109
|
+
<Animated.View testID="container" style={[styles.container, style]}>
|
|
110
|
+
<View testID="wrapper" style={[styles.content, contentStyle]}>
|
|
111
|
+
<Text testID="title" style={[styles.title, textStyle]}>
|
|
112
|
+
{title}
|
|
112
113
|
</Text>
|
|
113
114
|
</View>
|
|
114
|
-
<View style={[styles.tip,
|
|
115
|
+
<View testID="tip" style={[styles.tip, tipStyle]} />
|
|
115
116
|
</Animated.View>
|
|
116
117
|
);
|
|
117
|
-
}
|
|
118
|
+
};
|
|
118
119
|
|
|
119
|
-
_renderCustomCallout(): ReactElement {
|
|
120
|
+
const _renderCustomCallout = (): ReactElement => {
|
|
120
121
|
return (
|
|
121
|
-
<Animated.View {...
|
|
122
|
-
{
|
|
122
|
+
<Animated.View testID="container" {...props} style={style}>
|
|
123
|
+
{children}
|
|
123
124
|
</Animated.View>
|
|
124
125
|
);
|
|
125
|
-
}
|
|
126
|
+
};
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
128
|
+
const calloutContent = _hasChildren
|
|
129
|
+
? _renderCustomCallout()
|
|
130
|
+
: _renderDefaultCallout();
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<RCTMLNCallout testID="callout" style={_containerStyle}>
|
|
134
|
+
{calloutContent}
|
|
135
|
+
</RCTMLNCallout>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
138
|
|
|
139
139
|
const RCTMLNCallout = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
140
140
|
|