@maplibre/maplibre-react-native 9.1.0 → 10.0.0-alpha.2

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 (141) 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 +18 -0
  18. package/android/rctmgl/build.gradle +7 -7
  19. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/LocationManager.java +2 -2
  20. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.java +21 -26
  21. package/docs/Annotation.md +8 -9
  22. package/docs/BackgroundLayer.md +2 -10
  23. package/docs/Callout.md +5 -5
  24. package/docs/Camera.md +18 -47
  25. package/docs/CircleLayer.md +2 -10
  26. package/docs/FillExtrusionLayer.md +2 -10
  27. package/docs/FillLayer.md +2 -10
  28. package/docs/HeatmapLayer.md +2 -10
  29. package/docs/ImageSource.md +3 -2
  30. package/docs/Images.md +5 -3
  31. package/docs/Light.md +1 -1
  32. package/docs/LineLayer.md +2 -10
  33. package/docs/MapView.md +53 -37
  34. package/docs/MarkerView.md +4 -2
  35. package/docs/NativeUserLocation.md +2 -2
  36. package/docs/PointAnnotation.md +5 -8
  37. package/docs/RasterLayer.md +2 -10
  38. package/docs/RasterSource.md +3 -2
  39. package/docs/ShapeSource.md +12 -7
  40. package/docs/Style.md +1 -1
  41. package/docs/SymbolLayer.md +3 -10
  42. package/docs/UserLocation.md +8 -10
  43. package/docs/VectorSource.md +6 -5
  44. package/docs/coordinates.md +6 -0
  45. package/docs/docs.json +518 -1272
  46. package/docs/location.md +6 -0
  47. package/docs/snapshotManager.md +3 -3
  48. package/javascript/@types/assets.d.ts +4 -0
  49. package/javascript/MGLModule.ts +37 -0
  50. package/javascript/Maplibre.ts +65 -0
  51. package/javascript/components/AbstractLayer.tsx +107 -0
  52. package/javascript/components/AbstractSource.tsx +27 -0
  53. package/javascript/components/BackgroundLayer.tsx +43 -0
  54. package/javascript/components/{Callout.js → Callout.tsx} +67 -65
  55. package/javascript/components/{Camera.js → Camera.tsx} +266 -251
  56. package/javascript/components/CircleLayer.tsx +46 -0
  57. package/javascript/components/FillExtrusionLayer.tsx +47 -0
  58. package/javascript/components/FillLayer.tsx +41 -0
  59. package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +8 -8
  60. package/javascript/components/HeatmapLayer.tsx +44 -0
  61. package/javascript/components/ImageSource.tsx +78 -0
  62. package/javascript/components/Images.tsx +134 -0
  63. package/javascript/components/Light.tsx +67 -0
  64. package/javascript/components/LineLayer.tsx +42 -0
  65. package/javascript/components/{MapView.js → MapView.tsx} +365 -354
  66. package/javascript/components/MarkerView.tsx +104 -0
  67. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +44 -13
  68. package/javascript/components/NativeUserLocation.tsx +33 -0
  69. package/javascript/components/PointAnnotation.tsx +221 -0
  70. package/javascript/components/RasterLayer.tsx +41 -0
  71. package/javascript/components/RasterSource.tsx +117 -0
  72. package/javascript/components/ShapeSource.tsx +383 -0
  73. package/javascript/components/{Style.js → Style.tsx} +129 -38
  74. package/javascript/components/SymbolLayer.tsx +72 -0
  75. package/javascript/components/{UserLocation.js → UserLocation.tsx} +111 -110
  76. package/javascript/components/VectorSource.tsx +207 -0
  77. package/javascript/components/annotations/Annotation.tsx +134 -0
  78. package/javascript/index.ts +4 -0
  79. package/javascript/modules/location/{locationManager.js → locationManager.ts} +71 -10
  80. package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +20 -4
  81. package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +23 -7
  82. package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +81 -24
  83. package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +43 -6
  84. package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +5 -5
  85. package/javascript/requestAndroidLocationPermissions.ts +29 -0
  86. package/javascript/types/BaseProps.ts +5 -0
  87. package/javascript/types/OnPressEvent.ts +13 -0
  88. package/javascript/types/index.ts +7 -0
  89. package/javascript/utils/BridgeValue.ts +90 -0
  90. package/javascript/utils/{Logger.js → Logger.ts} +37 -18
  91. package/javascript/utils/MaplibreStyles.d.ts +1486 -0
  92. package/javascript/utils/StyleValue.ts +49 -0
  93. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +134 -0
  94. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +112 -0
  95. package/javascript/utils/animated/{AnimatedExtractCoordinateFromArray.js → AnimatedExtractCoordinateFromArray.ts} +5 -5
  96. package/javascript/utils/animated/{AnimatedPoint.js → AnimatedPoint.ts} +20 -12
  97. package/javascript/utils/animated/{AnimatedRouteCoordinatesArray.js → AnimatedRouteCoordinatesArray.ts} +39 -14
  98. package/javascript/utils/animated/{AnimatedShape.js → AnimatedShape.ts} +31 -10
  99. package/javascript/utils/{deprecation.js → deprecation.ts} +9 -6
  100. package/javascript/utils/filterUtils.ts +9 -0
  101. package/javascript/utils/geoUtils.ts +79 -0
  102. package/javascript/utils/{index.js → index.ts} +44 -24
  103. package/javascript/utils/styleMap.ts +264 -0
  104. package/package.json +35 -27
  105. package/plugin/build/withMapLibre.js +18 -3
  106. package/scripts/autogenHelpers/globals.js +1 -1
  107. package/scripts/autogenerate.js +14 -6
  108. package/scripts/download-style-spec.sh +1 -1
  109. package/scripts/templates/MaplibreStyles.ts.ejs +99 -0
  110. package/scripts/templates/index.d.ts.ejs +71 -42
  111. package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +3 -33
  112. package/setup-jest.js +1 -10
  113. package/tsconfig.json +20 -61
  114. package/index.d.ts +0 -955
  115. package/javascript/components/AbstractLayer.js +0 -75
  116. package/javascript/components/AbstractSource.js +0 -15
  117. package/javascript/components/BackgroundLayer.js +0 -97
  118. package/javascript/components/CircleLayer.js +0 -101
  119. package/javascript/components/FillExtrusionLayer.js +0 -98
  120. package/javascript/components/FillLayer.js +0 -94
  121. package/javascript/components/HeatmapLayer.js +0 -99
  122. package/javascript/components/ImageSource.js +0 -82
  123. package/javascript/components/Images.js +0 -119
  124. package/javascript/components/Light.js +0 -47
  125. package/javascript/components/LineLayer.js +0 -94
  126. package/javascript/components/MarkerView.js +0 -87
  127. package/javascript/components/NativeUserLocation.js +0 -41
  128. package/javascript/components/PointAnnotation.js +0 -216
  129. package/javascript/components/RasterLayer.js +0 -95
  130. package/javascript/components/RasterSource.js +0 -124
  131. package/javascript/components/ShapeSource.js +0 -372
  132. package/javascript/components/SymbolLayer.js +0 -120
  133. package/javascript/components/VectorSource.js +0 -200
  134. package/javascript/components/annotations/Annotation.js +0 -122
  135. package/javascript/index.js +0 -149
  136. package/javascript/utils/BridgeValue.js +0 -81
  137. package/javascript/utils/animated/AnimatedCoordinatesArray.js +0 -191
  138. package/javascript/utils/filterUtils.js +0 -7
  139. package/javascript/utils/geoUtils.js +0 -73
  140. package/javascript/utils/styleMap.js +0 -1932
  141. /package/javascript/utils/animated/{Animated.js → Animated.ts} +0 -0
@@ -0,0 +1,6 @@
1
+ <!-- This file was autogenerated from location.js do not modify -->
2
+ ## <MapLibreGL.location />
3
+ ### Location sent by locationManager
4
+
5
+
6
+
@@ -24,7 +24,7 @@ const uri = await MapLibreGL.snapshotManager.takeSnap({
24
24
  zoomLevel: 12,
25
25
  pitch: 30,
26
26
  heading: 20,
27
- styleURL: MapLibreGL.StyleURL.Dark,
27
+ styleURL: MapLibreGL.StyleURL.Default,
28
28
  writeToDisk: true, // Create a temporary file
29
29
  });
30
30
 
@@ -36,7 +36,7 @@ const uri = await MapLibreGL.snapshotManager.takeSnap({
36
36
  zoomLevel: 12,
37
37
  pitch: 30,
38
38
  heading: 20,
39
- styleURL: MapLibreGL.StyleURL.Dark,
39
+ styleURL: MapLibreGL.StyleURL.Default,
40
40
  withLogo: false, // Disable Mapbox logo (Android only)
41
41
  });
42
42
 
@@ -45,7 +45,7 @@ const uri = await MapLibreGL.snapshotManager.takeSnap({
45
45
  bounds: [[-74.126410, 40.797968], [-74.143727, 40.772177]],
46
46
  width: width,
47
47
  height: height,
48
- styleURL: MapLibreGL.StyleURL.Dark,
48
+ styleURL: MapLibreGL.StyleURL.Default,
49
49
  });
50
50
  ```
51
51
 
@@ -0,0 +1,4 @@
1
+ declare module '*.png' {
2
+ const content: number;
3
+ export default content;
4
+ }
@@ -0,0 +1,37 @@
1
+ import {NativeModules} from 'react-native';
2
+
3
+ interface IMGLModule {
4
+ StyleURL: {
5
+ Default: URL;
6
+ };
7
+ OfflinePackDownloadState: {
8
+ Inactive: string | number;
9
+ Active: string | number;
10
+ Complete: string | number;
11
+ Unknown?: string | number;
12
+ };
13
+ LineJoin: {
14
+ Bevel: string | number;
15
+ Round: string | number;
16
+ Miter: string | number;
17
+ };
18
+ StyleSource: {
19
+ DefaultSourceID: string;
20
+ };
21
+
22
+ setAccessToken(accessToken: string | null): Promise<string | null>;
23
+ getAccessToken(): Promise<string>;
24
+ setConnected(connected: boolean): void;
25
+ }
26
+
27
+ const MGLModule: IMGLModule = {...NativeModules.MGLModule};
28
+
29
+ export const {
30
+ StyleURL,
31
+ OfflinePackDownloadState,
32
+ LineJoin,
33
+ StyleSource,
34
+ setAccessToken,
35
+ getAccessToken,
36
+ setConnected,
37
+ } = MGLModule;
@@ -0,0 +1,65 @@
1
+ export * from './MGLModule';
2
+ export {
3
+ default as Camera,
4
+ UserTrackingMode,
5
+ type CameraPadding,
6
+ type CameraAnimationMode,
7
+ type CameraBounds,
8
+ } from './components/Camera';
9
+ export {default as MapView, type MapViewState} from './components/MapView';
10
+ export {default as Light} from './components/Light';
11
+ export {default as PointAnnotation} from './components/PointAnnotation';
12
+ export {default as Annotation} from './components/annotations/Annotation';
13
+ export {default as Callout} from './components/Callout';
14
+ export {requestAndroidLocationPermissions} from './requestAndroidLocationPermissions';
15
+ export {
16
+ default as UserLocation,
17
+ UserLocationRenderMode,
18
+ } from './components/UserLocation';
19
+ export {default as VectorSource} from './components/VectorSource';
20
+ export {default as ShapeSource} from './components/ShapeSource';
21
+ export {default as RasterSource} from './components/RasterSource';
22
+ export {default as ImageSource} from './components/ImageSource';
23
+ export {default as Images} from './components/Images';
24
+ export {default as FillLayer} from './components/FillLayer';
25
+ export {default as FillExtrusionLayer} from './components/FillExtrusionLayer';
26
+ export {default as HeatmapLayer} from './components/HeatmapLayer';
27
+ export {default as LineLayer} from './components/LineLayer';
28
+ export {default as CircleLayer} from './components/CircleLayer';
29
+ export {default as SymbolLayer} from './components/SymbolLayer';
30
+ export {default as RasterLayer} from './components/RasterLayer';
31
+ export {default as BackgroundLayer} from './components/BackgroundLayer';
32
+ export {
33
+ default as locationManager,
34
+ type Location,
35
+ } from './modules/location/locationManager';
36
+ export {default as offlineManager} from './modules/offline/offlineManager';
37
+ export {default as OfflineCreatePackOptions} from './modules/offline/OfflineCreatePackOptions';
38
+ export {default as snapshotManager} from './modules/snapshot/snapshotManager';
39
+ export type {SnapshotInputOptions} from './modules/snapshot/SnapshotOptions';
40
+ export {default as MarkerView} from './components/MarkerView';
41
+ export {default as Animated} from './utils/animated/Animated';
42
+ export {default as Style} from './components/Style';
43
+ export {default as Logger, type LogLevel} from './utils/Logger';
44
+ export type {
45
+ FillLayerStyleProps as FillLayerStyle,
46
+ LineLayerStyleProps as LineLayerStyle,
47
+ SymbolLayerStyleProps as SymbolLayerStyle,
48
+ CircleLayerStyleProps as CircleLayerStyle,
49
+ HeatmapLayerStyleProps as HeatmapLayerStyle,
50
+ FillExtrusionLayerStyleProps as FillExtrusionLayerStyle,
51
+ RasterLayerStyleProps as RasterLayerStyle,
52
+ HillshadeLayerStyleProps as HillshadeLayerStyle,
53
+ BackgroundLayerStyleProps as BackgroundLayerStyle,
54
+ LightLayerStyleProps as LightLayerStyle,
55
+ } from './utils/MaplibreStyles';
56
+
57
+ import {UserTrackingMode} from './components/Camera';
58
+
59
+ // types:
60
+ export enum StyleURL {
61
+ Default = 'https://demotiles.maplibre.org/style.json',
62
+ }
63
+
64
+ /** @deprecated UserTrackingModes is deprecated use UserTrackingMode */
65
+ export const UserTrackingModes = UserTrackingMode;
@@ -0,0 +1,107 @@
1
+ /* eslint react/prop-types:0 */
2
+ import {StyleValue, transformStyle} from '../utils/StyleValue';
3
+ import {getFilter} from '../utils/filterUtils';
4
+ import {AllLayerStyleProps, FilterExpression} from '../utils/MaplibreStyles';
5
+ import BaseProps from '../types/BaseProps';
6
+
7
+ import React from 'react';
8
+ import {processColor, NativeMethods} from 'react-native';
9
+
10
+ export interface BaseLayerProps {
11
+ /**
12
+ * A string that uniquely identifies the source in the style to which it is added.
13
+ */
14
+ id: string;
15
+ /**
16
+ * The source from which to obtain the data to style.
17
+ * If the source has not yet been added to the current style, the behavior is undefined.
18
+ * Inferred from parent source only if the layer is a direct child to it.
19
+ */
20
+ sourceID?: string;
21
+ /**
22
+ * Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style.
23
+ */
24
+ sourceLayerID?: string;
25
+ /**
26
+ * Inserts a layer above aboveLayerID.
27
+ */
28
+ aboveLayerID?: string;
29
+ /**
30
+ * Inserts a layer below belowLayerID
31
+ */
32
+ belowLayerID?: string;
33
+ /**
34
+ * Inserts a layer at a specified index
35
+ */
36
+ layerIndex?: number;
37
+ /**
38
+ * Filter only the features in the source layer that satisfy a condition that you define
39
+ */
40
+ /**
41
+ * The minimum zoom level at which the layer gets parsed and appears.
42
+ */
43
+ minZoomLevel?: number;
44
+ /**
45
+ * The maximum zoom level at which the layer gets parsed and appears.
46
+ */
47
+ maxZoomLevel?: number;
48
+ filter?: FilterExpression;
49
+ /**
50
+ * Customizable style attributes
51
+ */
52
+ style?: AllLayerStyleProps;
53
+ }
54
+
55
+ export interface NativeBaseProps {
56
+ reactStyle?: {[key: string]: StyleValue};
57
+ }
58
+
59
+ class AbstractLayer<
60
+ Props extends BaseProps,
61
+ NativeProps extends NativeBaseProps,
62
+ > extends React.PureComponent<Props & BaseLayerProps> {
63
+ get baseProps(): Props {
64
+ return {
65
+ ...this.props,
66
+ id: this.props.id,
67
+ sourceID: this.props.sourceID,
68
+ reactStyle: this.getStyle(),
69
+ minZoomLevel: this.props.minZoomLevel,
70
+ maxZoomLevel: this.props.maxZoomLevel,
71
+ aboveLayerID: this.props.aboveLayerID,
72
+ belowLayerID: this.props.belowLayerID,
73
+ layerIndex: this.props.layerIndex,
74
+ filter: getFilter(this.props.filter),
75
+ style: undefined,
76
+ };
77
+ }
78
+
79
+ nativeLayer: (React.Component<NativeProps> & Readonly<NativeMethods>) | null =
80
+ null;
81
+
82
+ setNativeLayer = (
83
+ instance: (React.Component<NativeProps> & Readonly<NativeMethods>) | null,
84
+ ): void => {
85
+ this.nativeLayer = instance;
86
+ };
87
+
88
+ getStyleTypeFormatter(styleType: string): typeof processColor | undefined {
89
+ return styleType === 'color' ? processColor : undefined;
90
+ }
91
+
92
+ getStyle(): {[key: string]: StyleValue} | undefined {
93
+ return transformStyle(this.props.style);
94
+ }
95
+
96
+ setNativeProps(props: {[key: string]: unknown}): void {
97
+ if (this.nativeLayer) {
98
+ let propsToPass = props;
99
+ if (props.style) {
100
+ propsToPass = {...props, reactStyle: this.getStyle()};
101
+ }
102
+ this.nativeLayer.setNativeProps(propsToPass);
103
+ }
104
+ }
105
+ }
106
+
107
+ export default AbstractLayer;
@@ -0,0 +1,27 @@
1
+ import BaseProps from '../types/BaseProps';
2
+
3
+ import React from 'react';
4
+ import {NativeMethods} from 'react-native';
5
+
6
+ class AbstractSource<
7
+ PropsType extends BaseProps,
8
+ NativePropsType extends object,
9
+ > extends React.PureComponent<PropsType> {
10
+ _nativeRef?: React.Component<NativePropsType> & Readonly<NativeMethods>;
11
+
12
+ setNativeProps(props: NativePropsType): void {
13
+ if (this._nativeRef) {
14
+ this._nativeRef.setNativeProps(props);
15
+ }
16
+ }
17
+
18
+ setNativeRef: (
19
+ instance: React.Component<NativePropsType> & Readonly<NativeMethods>,
20
+ ) => void = (
21
+ instance: React.Component<NativePropsType> & Readonly<NativeMethods>,
22
+ ) => {
23
+ this._nativeRef = instance;
24
+ };
25
+ }
26
+
27
+ export default AbstractSource;
@@ -0,0 +1,43 @@
1
+ import {BackgroundLayerStyleProps} from '../utils/MaplibreStyles';
2
+ import BaseProps from '../types/BaseProps';
3
+
4
+ import AbstractLayer, {BaseLayerProps, NativeBaseProps} from './AbstractLayer';
5
+
6
+ import React, {ReactNode} from 'react';
7
+ import {NativeModules, requireNativeComponent} from 'react-native';
8
+
9
+ const MapLibreGL = NativeModules.MGLModule;
10
+
11
+ export const NATIVE_MODULE_NAME = 'RCTMGLBackgroundLayer';
12
+
13
+ interface BackgroundLayerProps extends BaseProps, BaseLayerProps {
14
+ /**
15
+ * Customizable style attributes
16
+ */
17
+ style?: BackgroundLayerStyleProps;
18
+ }
19
+
20
+ interface NativeProps
21
+ extends Omit<BackgroundLayerProps, 'style'>,
22
+ NativeBaseProps {}
23
+
24
+ class BackgroundLayer extends AbstractLayer<BackgroundLayerProps, NativeProps> {
25
+ static defaultProps = {
26
+ sourceID: MapLibreGL.StyleSource.DefaultSourceID,
27
+ };
28
+
29
+ render(): ReactNode {
30
+ return (
31
+ <RCTMGLBackgroundLayer
32
+ testID="rctmglBackgroundLayer"
33
+ ref={this.setNativeLayer}
34
+ {...this.baseProps}
35
+ />
36
+ );
37
+ }
38
+ }
39
+
40
+ const RCTMGLBackgroundLayer =
41
+ requireNativeComponent<BackgroundLayerProps>(NATIVE_MODULE_NAME);
42
+
43
+ export default BackgroundLayer;
@@ -1,13 +1,13 @@
1
- import {viewPropTypes} from '../utils';
2
-
3
- import PropTypes from 'prop-types';
4
- import React from 'react';
1
+ import React, {ReactElement} from 'react';
5
2
  import {
6
3
  View,
7
4
  Text,
8
5
  Animated,
9
6
  requireNativeComponent,
10
7
  StyleSheet,
8
+ ViewStyle,
9
+ ViewProps,
10
+ StyleProp,
11
11
  } from 'react-native';
12
12
 
13
13
  export const NATIVE_MODULE_NAME = 'RCTMGLCallout';
@@ -19,28 +19,28 @@ const styles = StyleSheet.create({
19
19
  width: 180,
20
20
  zIndex: 9999999,
21
21
  },
22
+ content: {
23
+ backgroundColor: 'white',
24
+ borderColor: 'rgba(0, 0, 0, 0.2)',
25
+ borderRadius: 3,
26
+ borderWidth: 1,
27
+ flex: 1,
28
+ padding: 8,
29
+ position: 'relative',
30
+ },
22
31
  tip: {
23
- zIndex: 1000,
24
- marginTop: -2,
25
- elevation: 0,
26
32
  backgroundColor: 'transparent',
27
- borderTopWidth: 16,
28
- borderRightWidth: 8,
33
+ borderBottomColor: 'transparent',
29
34
  borderBottomWidth: 0,
35
+ borderLeftColor: 'transparent',
30
36
  borderLeftWidth: 8,
31
- borderTopColor: 'white',
32
37
  borderRightColor: 'transparent',
33
- borderBottomColor: 'transparent',
34
- borderLeftColor: 'transparent',
35
- },
36
- content: {
37
- position: 'relative',
38
- padding: 8,
39
- flex: 1,
40
- borderRadius: 3,
41
- borderWidth: 1,
42
- borderColor: 'rgba(0, 0, 0, 0.2)',
43
- backgroundColor: 'white',
38
+ borderRightWidth: 8,
39
+ borderTopColor: 'white',
40
+ borderTopWidth: 16,
41
+ elevation: 0,
42
+ marginTop: -2,
43
+ zIndex: 1000,
44
44
  },
45
45
  title: {
46
46
  color: 'black',
@@ -48,60 +48,62 @@ const styles = StyleSheet.create({
48
48
  },
49
49
  });
50
50
 
51
+ interface CalloutProps extends Omit<ViewProps, 'style'> {
52
+ /**
53
+ * String that get's displayed in the default callout.
54
+ */
55
+ title?: string;
56
+ /**
57
+ * Style property for the Animated.View wrapper, apply animations to this
58
+ */
59
+ style?: ViewStyle;
60
+ /**
61
+ * Style property for the native RCTMGLCallout container, set at your own risk.
62
+ */
63
+ containerStyle?: ViewStyle;
64
+ /**
65
+ * Style property for the content bubble.
66
+ */
67
+ contentStyle?: ViewStyle;
68
+ /**
69
+ * Style property for the triangle tip under the content.
70
+ */
71
+ tipStyle?: ViewStyle;
72
+ /**
73
+ * Style property for the title in the content bubble.
74
+ */
75
+ textStyle?: ViewStyle;
76
+ }
77
+
78
+ interface NativeProps extends Omit<CalloutProps, 'style'> {
79
+ style: StyleProp<ViewStyle>;
80
+ }
81
+
51
82
  /**
52
83
  * Callout that displays information about a selected annotation near the annotation.
53
84
  */
54
- class Callout extends React.PureComponent {
55
- static propTypes = {
56
- ...viewPropTypes,
57
-
58
- /**
59
- * String that get's displayed in the default callout.
60
- */
61
- title: PropTypes.string,
62
-
63
- /**
64
- * Style property for the Animated.View wrapper, apply animations to this
65
- */
66
- style: PropTypes.any,
67
-
68
- /**
69
- * Style property for the native RCTMGLCallout container, set at your own risk.
70
- */
71
- containerStyle: PropTypes.any,
72
-
73
- /**
74
- * Style property for the content bubble.
75
- */
76
- contentStyle: PropTypes.any,
77
-
78
- /**
79
- * Style property for the triangle tip under the content.
80
- */
81
- tipStyle: PropTypes.any,
82
-
83
- /**
84
- * Style property for the title in the content bubble.
85
- */
86
- textStyle: PropTypes.any,
87
- };
88
-
89
- get _containerStyle() {
90
- return [
85
+ class Callout extends React.PureComponent<CalloutProps> {
86
+ get _containerStyle(): ViewStyle[] {
87
+ const style = [
91
88
  {
92
89
  position: 'absolute',
93
90
  zIndex: 999,
94
91
  backgroundColor: 'transparent',
95
- },
96
- this.props.containerStyle,
92
+ } as ViewStyle,
97
93
  ];
94
+
95
+ if (this.props.containerStyle) {
96
+ style.push(this.props.containerStyle);
97
+ }
98
+
99
+ return style;
98
100
  }
99
101
 
100
- get _hasChildren() {
102
+ get _hasChildren(): boolean {
101
103
  return React.Children.count(this.props.children) > 0;
102
104
  }
103
105
 
104
- _renderDefaultCallout() {
106
+ _renderDefaultCallout(): ReactElement {
105
107
  return (
106
108
  <Animated.View style={[styles.container, this.props.style]}>
107
109
  <View style={[styles.content, this.props.contentStyle]}>
@@ -114,7 +116,7 @@ class Callout extends React.PureComponent {
114
116
  );
115
117
  }
116
118
 
117
- _renderCustomCallout() {
119
+ _renderCustomCallout(): ReactElement {
118
120
  return (
119
121
  <Animated.View {...this.props} style={this.props.style}>
120
122
  {this.props.children}
@@ -122,7 +124,7 @@ class Callout extends React.PureComponent {
122
124
  );
123
125
  }
124
126
 
125
- render() {
127
+ render(): ReactElement {
126
128
  const calloutContent = this._hasChildren
127
129
  ? this._renderCustomCallout()
128
130
  : this._renderDefaultCallout();
@@ -134,6 +136,6 @@ class Callout extends React.PureComponent {
134
136
  }
135
137
  }
136
138
 
137
- const RCTMGLCallout = requireNativeComponent(NATIVE_MODULE_NAME, Callout);
139
+ const RCTMGLCallout = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
138
140
 
139
141
  export default Callout;