1
1
import React from 'react' ;
2
- import { View , StyleSheet } from 'react-native' ;
2
+ import { View , StyleSheet , Text } from 'react-native' ;
3
3
import MapView from 'react-native-maps' ;
4
4
5
5
import { storiesOf } from '@storybook/react' ;
@@ -8,7 +8,8 @@ import { action } from '@storybook/addon-actions';
8
8
storiesOf ( 'MapView' , module )
9
9
. add ( 'basic' , ( ) => (
10
10
< View style = { styles . container } >
11
- < MapView region = { { latitude : 48.86 , longitude : 2.34 } } />
11
+ < MapView defaultZoom = { 15 } region = { { latitude : 48.86 , longitude : 2.34 } } />
12
+ < MapView defaultZoom = { 10 } region = { { latitude : 48.86 , longitude : 2.34 } } />
12
13
</ View >
13
14
) )
14
15
. add ( 'onRegionChangeComplete' , ( ) => (
@@ -27,7 +28,12 @@ storiesOf('MapView', module)
27
28
. add ( 'options' , ( ) => (
28
29
< View style = { styles . container } >
29
30
< MapView
30
- initialRegion = { { latitude : 48.86 , longitude : 2.34 } }
31
+ initialRegion = { {
32
+ latitude : 48.86 ,
33
+ longitude : 2.34 ,
34
+ latitudeDelta : 0.1 ,
35
+ longitudeDelta : 0.1 ,
36
+ } }
31
37
options = { {
32
38
zoomControlOptions : {
33
39
position : window . google . maps . ControlPosition . RIGHT_CENTER ,
@@ -40,17 +46,62 @@ storiesOf('MapView', module)
40
46
</ View >
41
47
) ) ;
42
48
43
- storiesOf ( 'Marker' , module ) . add ( 'basic' , ( ) => (
44
- < View style = { styles . container } >
45
- < MapView region = { { latitude : 48.88 , longitude : 2.32 } } >
46
- < MapView . Marker
47
- title = "BAM"
48
- description = "Shape the future of mobile with us"
49
- coordinate = { { latitude : 48.8828463 , longitude : 2.3229091 } }
50
- />
51
- </ MapView >
52
- </ View >
53
- ) ) ;
49
+ storiesOf ( 'Marker' , module )
50
+ . add ( 'basic' , ( ) => (
51
+ < View style = { styles . container } >
52
+ < MapView ref = { map => ( this . map = map ) } region = { { latitude : 48.88 , longitude : 2.32 } } >
53
+ < MapView . Marker
54
+ title = "BAM"
55
+ description = "Shape the future of mobile with us"
56
+ coordinate = { { latitude : 48.8828463 , longitude : 2.3229091 } }
57
+ onPress = { ( ) => {
58
+ this . map . animateToRegion ( {
59
+ latitude : 48.8828463 ,
60
+ longitude : 2.3229091 ,
61
+ latitudeDelta : 0.1 ,
62
+ longitudeDelta : 0.1 ,
63
+ } ) ;
64
+ } }
65
+ />
66
+ < MapView . Marker
67
+ title = "BAM"
68
+ description = "Shape the future of mobile with us"
69
+ coordinate = { { latitude : 48.8828463 , longitude : 2.3 } }
70
+ onPress = { ( ) => {
71
+ console . log ( this . map . getCamera ( ) ) ;
72
+ const zoom = this . map . getCamera ( ) . zoom === 20 ? 15 : 20 ;
73
+ this . map . animateCamera ( {
74
+ zoom,
75
+ center : {
76
+ lat : 48.8828463 ,
77
+ lng : 2.3 ,
78
+ } ,
79
+ } ) ;
80
+ } }
81
+ />
82
+ </ MapView >
83
+ </ View >
84
+ ) )
85
+ . add ( 'Callout' , ( ) => (
86
+ < View style = { styles . container } >
87
+ < MapView ref = { map => ( this . map = map ) } region = { { latitude : 48.88 , longitude : 2.32 } } >
88
+ < MapView . Marker
89
+ title = "BAM"
90
+ ref = { marker => ( this . marker = marker ) }
91
+ description = "Shape the future of mobile with us"
92
+ coordinate = { { latitude : 48.8828463 , longitude : 2.3229091 } }
93
+ onPress = { ( ) => {
94
+ this . marker1 . showCallout ( ) ;
95
+ } } >
96
+ < MapView . Callout onPress = { action ( 'onPress callout' ) } >
97
+ < View style = { { padding : 10 } } >
98
+ < Text > Paris</ Text >
99
+ </ View >
100
+ </ MapView . Callout >
101
+ </ MapView . Marker >
102
+ </ MapView >
103
+ </ View >
104
+ ) ) ;
54
105
55
106
const styles = StyleSheet . create ( {
56
107
container : {
0 commit comments