11import React from 'react' ;
2- import { View , StyleSheet } from 'react-native' ;
2+ import { View , StyleSheet , Text } from 'react-native' ;
33import MapView from 'react-native-maps' ;
44
55import { storiesOf } from '@storybook/react' ;
@@ -8,7 +8,8 @@ import { action } from '@storybook/addon-actions';
88storiesOf ( 'MapView' , module )
99 . add ( 'basic' , ( ) => (
1010 < 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 } } />
1213 </ View >
1314 ) )
1415 . add ( 'onRegionChangeComplete' , ( ) => (
@@ -27,7 +28,12 @@ storiesOf('MapView', module)
2728 . add ( 'options' , ( ) => (
2829 < View style = { styles . container } >
2930 < 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+ } }
3137 options = { {
3238 zoomControlOptions : {
3339 position : window . google . maps . ControlPosition . RIGHT_CENTER ,
@@ -40,17 +46,62 @@ storiesOf('MapView', module)
4046 </ View >
4147 ) ) ;
4248
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+ ) ) ;
54105
55106const styles = StyleSheet . create ( {
56107 container : {
0 commit comments