在airbnb / react-native-maps中自定义我的位置按钮

bps*_*v21 8 reactjs react-native airbnb-js-styleguide

我已使用airbnb / react-native-maps设计基于跟踪的应用程序。我设计了一个自定义搜索框。但是问题是,搜索框与我的位置按钮重叠。有什么方法可以自定义我的位置按钮并更改其对齐位置?我附了一张照片以获取更多说明。

这是我使用的示例代码

                 <MapView
                    provider={PROVIDER_GOOGLE}
                    style={styles.map}
                    region={{
                        latitude: this.props.initialPosition.latitude,
                        longitude: this.props.initialPosition.longitude,
                        latitudeDelta: Latitude_Delta,
                        longitudeDelta: Longitude_Delta
                    }}
                    zoomEnabled={true}
                    minZoomLevel={5}
                    maxZoomLevel={20}
                    showsMyLocationButton={true}
                    showsUserLocation={true}
                    ... ... ...
                   >
                   {... ... ... ...}
                   </MapView>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

kes*_*lal 0

一个快速的解决方案是在地图的顶部添加一个填充,其高度与您的高度相同custom-search-box,以将其推到myLocationButton其下方。

我浏览了它的文档,但找不到任何方法来自定义其位置或对齐方式。

6 个多月前,github 上有一个类似的问题提出了类似的解决方案:

https://github.com/airbnb/react-native-maps/issues/1094

  • 我见过这个问题。但就我而言,这是不合适的。此外,我只想自定义 myLocationButton 。并需要帮助才能做到这一点 (2认同)