ShowsMyLocationButton 未显示在 iOS 上(react-native-maps)
ShowsMyLocationButton not showing on iOS (react-native-maps)
showsMyLocationButton 选项在 iOS 上不起作用。最初按钮也没有显示在 Android 上,但我在实施 github 问题(强制重新渲染)中建议的 hack 后显示了它。
如何显示 iOS 上的按钮?我应该自己制作按钮吗?
<MapView
style={styles.map, { flex: 1, marginBottom: this.state.marginBottom }}
onMapReady={this._onMapReady}
initialRegion={initialRegion}
showsUserLocation={true}
//onPanDrag={e => console.log(e.nativeEvent)}
followsUserLocation={true}
showsMyLocationButton={true}
>
react-native-maps: 0.21.0
反应:16.4.1
按照以下步骤实现了我自己的按钮:https://github.com/react-community/react-native-maps/issues/209#issuecomment-350907665
我定义供应商映射如下:
provider={MapView.PROVIDER_GOOGLE}
在地图视图中
现在一切正常。
你也可以把MapView
换成View
,设置style然后加上onMapReady
,如下:
<View style={{paddingTop: this.state.paddingTop}}>
<MapView
...
onMapReady={() => {
this.setState({ paddingTop: 5 })
}}
...
</MapView>
</View>
不过有点脏
showsMyLocationButton 选项在 iOS 上不起作用。最初按钮也没有显示在 Android 上,但我在实施 github 问题(强制重新渲染)中建议的 hack 后显示了它。
如何显示 iOS 上的按钮?我应该自己制作按钮吗?
<MapView
style={styles.map, { flex: 1, marginBottom: this.state.marginBottom }}
onMapReady={this._onMapReady}
initialRegion={initialRegion}
showsUserLocation={true}
//onPanDrag={e => console.log(e.nativeEvent)}
followsUserLocation={true}
showsMyLocationButton={true}
>
react-native-maps: 0.21.0
反应:16.4.1
按照以下步骤实现了我自己的按钮:https://github.com/react-community/react-native-maps/issues/209#issuecomment-350907665
我定义供应商映射如下:
provider={MapView.PROVIDER_GOOGLE}
在地图视图中 现在一切正常。
你也可以把MapView
换成View
,设置style然后加上onMapReady
,如下:
<View style={{paddingTop: this.state.paddingTop}}>
<MapView
...
onMapReady={() => {
this.setState({ paddingTop: 5 })
}}
...
</MapView>
</View>
不过有点脏