absoluteFillObject这是让地图正常工作的唯一方法吗?
我想以这种方式分配屏幕
map - flex 3
bottom layout (eg taxi details) - flex 1但我无法让地图与flex (可变大小)一起工作,而不会得到关于地图大小不能为0的错误
地图不要使用整个屏幕,这一点很重要,因为地图的中心不是屏幕的中心,因为我们有使用部分屏幕的底部布局
作为一种解决办法,我使用marginBottom来避免底部布局高度,但这样我必须为底部布局提供固定的高度,并且失去了灵活的大小
发布于 2019-04-22 11:59:39
<View style={{width:'100%', height:'100%'}}>
<Map style={{width:'100%', height:'75%'}}></Map>
<OtherComponent style={{width:'100%', height:'25%'}}></OtherComponent>
</View>我在使用Map和flex组合时也遇到了同样的问题。我只是给出了高度的百分比和它的工作为我。您可以尝试使用上面的代码来解决您的问题。
发布于 2021-10-06 10:44:35
Nirmalsinh的解决方案可以工作,但我建议只将地图视图包装在flex容器中,例如:
<View style={{flex: 1}}>
<View style={{flex: 1}}>
<MapView height: '100%'}}/>
</View>
</OtherComponent>
</View>发布于 2019-04-22 13:10:37
这对我很有效..。
<View style={styles.container}>
<MapView
style={styles.map}
/>
</View>以及风格,
container: {
...StyleSheet.absoluteFillObject,
height: 540, // you can customize this
width: 400, // you can customize this
alignItems: "center"
},
map: {
...StyleSheet.absoluteFillObject
}https://stackoverflow.com/questions/55788907
复制相似问题