forked from react-native-maps/react-native-maps
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMapCallout.tsx
76 lines (68 loc) · 2.02 KB
/
MapCallout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import * as React from 'react';
import {StyleSheet, ViewProps} from 'react-native';
import decorateMapComponent, {
MapManagerCommand,
NativeComponent,
ProviderContext,
SUPPORTED,
UIManagerCommand,
USES_DEFAULT_IMPLEMENTATION,
} from './decorateMapComponent';
import {CalloutPressEvent} from './sharedTypes';
export type MapCalloutProps = ViewProps & {
/**
* If `true`, clicks on transparent areas in callout will be passed to map.
*
* @default false
* @platform iOS: Supported
* @platform Android: Not supported
*/
alphaHitTest?: boolean;
/**
* Callback that is called when the user presses on the callout
*
* @platform iOS: Apple Maps only
* @platform Android: Supported
*/
onPress?: (event: CalloutPressEvent) => void;
/**
* If `false`, a default "tooltip" bubble window will be drawn around this callouts children.
* If `true`, the child views can fully customize their appearance, including any "bubble" like styles.
*
* @default false
* @platform iOS: Supported
* @platform Android: Supported
*/
tooltip?: boolean;
};
type NativeProps = MapCalloutProps;
export class MapCallout extends React.Component<MapCalloutProps> {
// declaration only, as they are set through decorateMap
declare context: React.ContextType<typeof ProviderContext>;
getNativeComponent!: () => NativeComponent<NativeProps>;
getMapManagerCommand!: (name: string) => MapManagerCommand;
getUIManagerCommand!: (name: string) => UIManagerCommand;
render() {
const {tooltip = false, alphaHitTest = false} = this.props;
const AIRMapCallout = this.getNativeComponent();
return (
<AIRMapCallout
{...this.props}
tooltip={tooltip}
alphaHitTest={alphaHitTest}
style={[styles.callout, this.props.style]}
/>
);
}
}
const styles = StyleSheet.create({
callout: {
position: 'absolute',
},
});
export default decorateMapComponent(MapCallout, 'Callout', {
google: {
ios: SUPPORTED,
android: USES_DEFAULT_IMPLEMENTATION,
},
});