reactjs - 无法渲染来自 react-native-maps
问题描述
我正在尝试使用示例中的坐标显示本机地图,但出现错误:
*注意使用ios和真机调试
错误:
Could not inset compass from edges 9
Could not inset scale from edge
Could not inset legal attribution from corner 4
代码:
class Map extends Component {
constructor(props) {
super(props);
}
render() {
console.log('map render')
return (
<MapView
provider={null}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
);
}}
项目示例:这里
解决方案
这是样式的问题。我能够用这段代码修复它:
render() {
return (
<View style={styles.container}>
<MapView
style={styles.map}
provider={null}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</View>
);
}
}
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,
},
});
推荐阅读
- javascript - 如何为图像地图区域设置背景颜色
- python - 抖动后的透明背景看起来很奇怪 - 枕头
- django - Django:在模板中显示相关项目的总和
- java - Firebase onComplete 从未在 Android 10 中调用
- node.js - 如何从 GCP 授予 Firebase Functions 访问资源的权限?(如 GCE)
- javascript - Mongo 块未写入
- java - GCP 机器映像 - 获取项目的映像列表
- css - 如何在 wordpress 主题中更改网站标题字体样式 Bizberg Consulting Dark
- javascript - 将id传递给jquery函数
- erlang - 了解 Erlang 列表理解生成器