react-native - 如何使用react-native-maps显示地图
问题描述:
我试图使用react-native-maps显示地图视图。 该组件似乎正在显示,但它是空白的。react-native - 如何使用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
从项目根目录下的反应,本机地图与您的项目联系起来。 (或者你可以按照这里列出的手动步骤:https://github.com/airbnb/react-native-maps/blob/master/docs/installation.md#option-3-manually)
你有没有试过在他们的[文档]中设置样式(https://github.com/airbnb/react-native-maps/blob/master/文档/ installation.md) –