我在这个问题上遇到了同样的问题: react-native - How to display map using react-native-maps
有人建议执行react-native link
来解决此问题,但这对我不起作用。
这个问题还有其他解决办法吗?
屏幕:
import React, { Component } from 'react';
import { StyleSheet, View, Dimensions } from 'react-native';
import MapView from 'react-native-maps';
var { width, height} = Dimensions.get('window');
const styles = StyleSheet.create({
container: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
width: width,
height: height
},
});
class TestMap extends Component {
constructor() {
super();
}
render() {
return (
<View style={ styles.container }>
<MapView
style={ styles.map }
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</View>
);
}
}
export default TestMap;
答案 0 :(得分:0)
尝试重写这样的样式:
const styles = StyleSheet.create({
container: {
flex: 1,
},
map: {
flex: 1,
},
});