首页 > 解决方案 > showMyLocationButton 未在 Android 8 上显示

问题描述

react-native-maps在 android 6 及更低版本上使用它是 Okey。

但在更高版本的 Android 中,它不显示MyLocationButton.

<MapView
    zoomControlEnabled

    showsMyLocationButton={true}
    showsUserLocation={true}
>
    {this.state.markers}
</MapView>

标签: react-nativereact-native-androidreact-native-maps

解决方案


以下代码适用于我并显示 MyLocationButton。

  <MapView
    customMapStyle={MapStyle}
    style={styles.map}
    provider="google"
    showsUserLocation
    renderMarker={this.renderMarker}
  />

如果最后你做不到,你可以创建一个示例按钮并在其 onPress 上,mapAnimateToRegion转到用户位置。


推荐阅读