如何在反应原生地图集GL中放置浮动按钮

问题描述 投票:0回答:1

我正在使用React native并使用Mapbox GL库来显示地图。现在我想在Mapbox GL视图的中心添加一个按钮。以下是我得到的。 screenshot

这是代码。

      <View style={styles.container}>

        <Mapbox.MapView
          style={{flex: 1}}
          styleURL={Mapbox.StyleURL.Dark}
          zoomLevel={15}
          centerCoordinate={[79.900424, 6.867281]}
          showUserLocation={true}
          logoEnabled={false}
          rotateEnabled={false}
          attributionEnabled={false}
          animated={true}
          style={styles.container}>
        </Mapbox.MapView>

        <View style={{width:30, backgroundColor:"transparent"}}>
          <Button title="Button"></Button>
        </View>

      </View>

      const styles = StyleSheet.create({
        container: {
          flex: 1,
        }
      });

我怎么解决这个问题?

react-native mapbox mapbox-gl react-native-mapbox-gl
1个回答
1
投票

试试这个,

<View style={{width:30, backgroundColor:"transparent",position:'absolute',top:"50%",left:"50%",zIndex:10}}>
    <Button title="Button"></Button>
</View>
© www.soinside.com 2019 - 2024. All rights reserved.