【问题标题】:Why is mapPadding Prop not giving any padding on iOS devices when padding is specified?为什么在指定填充时 mapPadding Prop 没有在 iOS 设备上提供任何填充?
【发布时间】: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


    【解决方案1】:

    我设法让mapPadding 在两个平台上同样工作的唯一方法是使用provider={PROVIDER_GOOGLE},这需要一些额外的配置才能在 iOS 上工作。这使得地图在两个平台上的外观和工作方式基本相同。

    【讨论】:

      猜你喜欢
      • 2015-09-14
      • 2020-04-28
      • 2017-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-08
      • 1970-01-01
      • 2017-09-07
      相关资源
      最近更新 更多