[英]react-native - How to display map using react-native-maps
我正在尝试使用react-native-maps显示一个地图视图。 该组件似乎为显示,但其为空白。
是我的样式表还是我叫“ MapView”组件正确吗?
这是代码:
var MapView = require('react-native-maps');
class Map extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
render() {
return (
<View style={styles.container}>
<MapView style={styles.map}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0,
longitudeDelta: 0.0,
}}
/>
</View>
);
}
};
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
map: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}
});
跑
$react-native link
从项目根目录中将react-native-maps与您的项目链接。 (或者您可以按照此处列出的这些手动步骤操作: https : //github.com/airbnb/react-native-maps/blob/master/docs/installation.md#option-3-manually )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.