Skip to content

Commit 325ad09

Browse files
committed
Able to customize container style
1 parent d8b675f commit 325ad09

2 files changed

Lines changed: 32 additions & 15 deletions

File tree

docs/stories/index.js

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
import React from 'react';
2-
import { View } from 'react-native';
2+
import { View, StyleSheet } from 'react-native';
33
import MapView from 'react-native-maps';
44

55
import { storiesOf } from '@storybook/react';
66
import { action } from '@storybook/addon-actions';
77

88
storiesOf('MapView', module)
9-
.add('basic', () => <MapView region={{ latitude: 48.86, longitude: 2.34 }} />)
9+
.add('basic', () => (
10+
<View style={styles.container}>
11+
<MapView region={{ latitude: 48.86, longitude: 2.34 }} />
12+
</View>
13+
))
1014
.add('onRegionChangeComplete', () => (
11-
<View>
15+
<View style={styles.container}>
1216
<MapView
1317
region={{ latitude: 48.86, longitude: 2.34 }}
1418
onRegionChangeComplete={action('onRegionChangeComplete toggled')}
1519
/>
1620
</View>
1721
))
1822
.add('onPress', () => (
19-
<View>
23+
<View style={styles.container}>
2024
<MapView region={{ latitude: 48.86, longitude: 2.34 }} onPress={action('onPress toggled')} />
2125
</View>
2226
));
27+
2328
storiesOf('Marker', module).add('basic', () => (
24-
<MapView region={{ latitude: 48.88, longitude: 2.32 }}>
25-
<MapView.Marker
26-
title="BAM"
27-
description="Shape the future of mobile with us"
28-
coordinate={{ latitude: 48.8828463, longitude: 2.3229091 }}
29-
/>
30-
</MapView>
29+
<View style={styles.container}>
30+
<MapView region={{ latitude: 48.88, longitude: 2.32 }}>
31+
<MapView.Marker
32+
title="BAM"
33+
description="Shape the future of mobile with us"
34+
coordinate={{ latitude: 48.8828463, longitude: 2.3229091 }}
35+
/>
36+
</MapView>
37+
</View>
3138
));
39+
40+
const styles = StyleSheet.create({
41+
container: {
42+
height: '100vh',
43+
},
44+
});

src/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ class MapView extends Component {
2323
};
2424

2525
render() {
26-
if (!this.state.center)
26+
const style = this.props.style || styles.container;
27+
28+
if (!this.state.center) {
2729
return (
28-
<View style={styles.container}>
30+
<View style={style}>
2931
<ActivityIndicator />
3032
</View>
3133
);
34+
}
35+
3236
return (
33-
<View style={styles.container}>
37+
<View style={style}>
3438
<GoogleMapContainer
3539
handleMapMounted={this.handleMapMounted}
3640
containerElement={<div style={{ height: '100%' }} />}
@@ -52,7 +56,7 @@ MapView.Polyline = Polyline;
5256

5357
const styles = StyleSheet.create({
5458
container: {
55-
height: '100vh',
59+
height: '100%',
5660
},
5761
});
5862

0 commit comments

Comments
 (0)