【发布时间】:2020-09-22 23:44:16
【问题描述】:
我遇到了一个问题,在使用 react-native-maps 渲染地图时,我们无法仅在 iOS 设备上显示地图填充。
这很有趣,因为 Android 设备确实可以正确显示地图内边距,但 iOS 设备在设置该属性时根本不会显示任何内边距。
关于 mapPadding,以下代码适用于 Android 设备,但不适用于 iOS 设备:
<MapView
ref={(map) => (this.map = map)}
mapPadding={{ top: 0, right: 0, bottom: 550, left: 0 }}
paddingAdjustmentBehavior="always"
initialRegion={{
latitude: 30.2303 - 0.0123,
longitude: -97.7538,
latitudeDelta: 0.2,
longitudeDelta: 0.1,
}}
style={styles.mapStyle}
>
{crawlCard.map((crawl, index) => {
return (
<Marker
coordinate={{
latitude: crawl.coords.lat,
longitude: crawl.coords.lon,
}}
title={crawl.title}
key={index}
onSelect={() => {
this.map.animateToRegion(
{
latitude: crawl.coords.lat,
longitude: crawl.coords.lon,
},
200
);
}}
/>
);
})}
</MapView>
我们是否需要实现其他任何功能/方法才能让这个 mapPadding 道具在 iOS 设备上工作?我的团队和我见过的所有示例都在两个平台上都使用了 mapPadding。
我们正在使用: 反应原生 5.x react-native-maps 0.26.1
任何帮助将不胜感激。谢谢!
【问题讨论】:
标签: android ios react-native google-maps react-native-maps