【问题标题】:react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOSreact-native-maps:必须将 AirGoogleMaps 目录添加到您的 xCode 项目中以支持 iOS 上的 GoogleMaps
【发布时间】:2019-04-25 10:58:05
【问题描述】:

我正在尝试在 iOS 上使用谷歌地图,但出现此错误:

react-native-maps:必须将 AirGoogleMaps 目录添加到您的 xCode 项目中才能支持 iOS 上的 GoogleMaps。

Error Image

我正在使用 react-native.maps https://github.com/react-community/react-native-maps

我按照安装说明进行操作,在 Android 中它运行良好,但在 IOS 中却没有

macOS:10.14.1 (18B75)

dependencies {

"react": "16.5.0",

"react-native": "0.57.1",

"react-native-maps": "^0.22.1",

}

【问题讨论】:

  • 你在使用 cocoapods 吗?您真的按照 iOS 的说明进行操作吗?它们不一样,如果你想渲染谷歌地图,它有额外的步骤。
  • @HelmerBarcos 是的,我正在使用 cocoapods,我将 AirGoogleMaps 文件夹添加到我的 xcworkspace,将 AirMaps.xcodeproj 添加到 mi Libraries 文件夹并添加到我的 AppDelegate.m #import <GoogleMaps/GoogleMaps.h> [GMSServices provideAPIKey:@"_API_KEY_"];

标签: ios reactjs google-maps react-native react-native-maps


【解决方案1】:

安装库 react-native-maps。按照链接说明进行操作

https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.md

【讨论】:

    【解决方案2】:

    将此条件添加到您的

    provider={Platform.OS === 'android' ? PROVIDER_GOOGLE : PROVIDER_DEFAULT}

    【讨论】:

      【解决方案3】:

      或者,如果提供者对您不重要,只需删除 MapView 中的以下属性:

      provider={MapView.PROVIDER_GOOGLE}

      它为我解决了这个问题

      【讨论】:

        【解决方案4】:

        好的,我刚刚遇到了同样的问题,所以我是这样解决的:

        首先在此处关注此答案:

        https://github.com/react-community/react-native-maps/issues/693#issuecomment-262656417

        然后你需要进入 xcode > build settings > Preprocessor Macros > add HAVE_GOOGLE_MAPS=1

        P.S 在我使用的实际组件中

        import MapView from "react-native-maps";
        
        <MapView provider={MapView.PROVIDER_GOOGLE} style={styles.map} />
        

        我的风格> 地图:{ 位置:“绝对”, 顶部:0, 左:0, 底部:0, 右:0 }

        希望这会有所帮助;)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-10-09
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多