【问题标题】:ShowsMyLocationButton not showing on iOS (react-native-maps)ShowsMyLocationButton 未在 iOS 上显示(react-native-maps)
【发布时间】:2019-04-27 18:55:14
【问题描述】:

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

【问题讨论】:

标签: ios react-native react-native-maps


【解决方案1】:

你也可以将MapView包装成View,设置style并添加onMapReady如下:

  <View style={{paddingTop: this.state.paddingTop}}> 
    <MapView

      ...

      onMapReady={() => {
        this.setState({ paddingTop: 5 })
      }}

      ...

    </MapView>
  </View>

但是有点脏。

【讨论】:

    【解决方案2】:

    我将提供者定义为这样映射:

    provider={MapView.PROVIDER_GOOGLE}
    

    在地图视图中 现在一切正常。

    【讨论】:

      【解决方案3】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-11-19
        • 2018-07-09
        • 2019-05-08
        • 1970-01-01
        • 2018-04-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多