首页 > 解决方案 > getMapBoundaries 方法未定义

问题描述

我在我的 React Native Expo 应用程序中使用“react-native-maps”:“^0.22.1”。

我试图在我的代码中使用 getMapBoundaries() 方法,但该方法未定义。请注意,例如,我可以使用 animateToRegion() 方法。

  <MapView
    style={styles.mapView}
    ref={ref => {
      this.map = ref;
    }}
    onRegionChangeComplete={this.handleRegionChange}
    provider={MapView.PROVIDER_GOOGLE}
    showsUserLocation={true}
    showsCompass={true}
    showsScale={true}
    onMapReady={this.handleMapReady}
  >
  </MapView>

当我调用 getMapBoundaries() 方法时,我收到“不是函数”错误。

this.map.getMapBoundaries()

如果您需要更多信息,请告诉我。
对你的帮助表示感谢。

标签: react-nativereact-native-maps

解决方案


请参考issue #2665,“npm 尚未发布有此方法的版本,请使用 git 版本。”


推荐阅读