地图视图不在滚动条上移动
map view not moving on scroll
我正在处理 React Native 地图,在地图上添加视图后,地图没有滚动。
通常,当我向下或向上滚动时,我会看到地图的不同部分。但是,添加 View
后,地图固定在一个位置,我看不到地图的不同部分。
<MapView
provider={PROVIDER_GOOGLE}
initialRegion={this.state.region}
showsUserLocation = {true}
ref="map"
>
<View
style={{flex: 3, alignSelf: 'stretch',
textAlign: 'center'}}
>
<Button title="click here"/>
</View>
</MapView>
我需要 view
的原因是添加其他组件,如按钮输入字段等。
docs 表示您需要绝对定位要在地图上添加其他视图的组件
Absolutely position these elements.
试试这个
render() {
return (
<MapView
region={this.state.region}
/>
<OverlayComponent
style={{position: “absolute”, bottom: 50}}
/>
);
}
我正在处理 React Native 地图,在地图上添加视图后,地图没有滚动。
通常,当我向下或向上滚动时,我会看到地图的不同部分。但是,添加 View
后,地图固定在一个位置,我看不到地图的不同部分。
<MapView
provider={PROVIDER_GOOGLE}
initialRegion={this.state.region}
showsUserLocation = {true}
ref="map"
>
<View
style={{flex: 3, alignSelf: 'stretch',
textAlign: 'center'}}
>
<Button title="click here"/>
</View>
</MapView>
我需要 view
的原因是添加其他组件,如按钮输入字段等。
docs 表示您需要绝对定位要在地图上添加其他视图的组件
Absolutely position these elements.
试试这个
render() {
return (
<MapView
region={this.state.region}
/>
<OverlayComponent
style={{position: “absolute”, bottom: 50}}
/>
);
}