ios - 如何在 react native map 上获取中心坐标?

标签 ios dictionary react-native

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

最佳答案

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

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

The region to be displayed by the map.

The region is defined by the center coordinates and the span of coordinates to display.

因此,您可以使用 map 的 region 获取中心坐标属性,使用类似的东西

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

如果你需要一个全局变量传递给getCoordinates ,您可以使用一个全局变量,该变量随各种状态变化时设置的新值而变化,例如 onRegionChange .

关于ios - 如何在 react native map 上获取中心坐标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32315425/

相关文章:

ios - iOS 通用链接支持在没有 Web 服务器的情况下工作吗?

ios - Swift:沿贝塞尔路径渐变(使用 CALayers)

c# - 高效地更新 .NET 字典中的绑定(bind)

c# - 字典在后台加载

react-native - React Native FlatList Item onLayout 总是返回 y : 0, x: 0

react-native - 如何将图像位置作为 Prop 传递给另一个组件并在 require 方法中使用它

ios - 接口(interface) Object() {} 和 @implementation Object @end 中的变量之间的区别

iphone - 在表格 View 部分标题中垂直居中 UILabel 文本

C# Indexer 属性 - 有什么方法可以虚拟化 get 而不是 set 方法?

javascript - 我的 useState 有问题吗?我觉得我的 Array ReactNative 中的值不正确