【问题标题】:How to get the center coordinate on react-native map?如何在 react-native 地图上获取中心坐标?
【发布时间】:2015-11-25 17:37:55
【问题描述】:

我正在使用 react-native。如何获取 iOS 地图的中心坐标?

【问题讨论】:

    标签: ios dictionary react-native


    【解决方案1】:

    发件人:https://facebook.github.io/react-native/docs/mapview.html#content

    region {latitude: number, longitude: number, latitudeDelta: number, longitudeDelta: number}

    地图要显示的区域。

    区域由中心坐标和跨度定义 要显示的坐标。

    因此,您可以使用地图的 region 属性获取中心坐标,例如

    getCoordinates(region) {
        return [{
          longitude: region.longitude,
          latitude: region.latitude,
        }];
    },
    

    如果您需要一个全局变量来传递给getCoordinates,您可以使用一个全局变量,该变量会随着onRegionChange 等各种状态变化而设置一个新值。

    【讨论】:

    • 我很高兴!如果可以的话,请投票/标记为正确(这是我的第一个答案 - 很高兴最终做出贡献)。
    • 你必须听 onRegionChangeComplete 来获取区域。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    相关资源
    最近更新 更多