Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 有人能将react原生地图与Google地图一起使用吗?_React Native_Google Maps_Axios_React Native Maps - Fatal编程技术网

React native 有人能将react原生地图与Google地图一起使用吗?

React native 有人能将react原生地图与Google地图一起使用吗?,react-native,google-maps,axios,react-native-maps,React Native,Google Maps,Axios,React Native Maps,我目前有一个react原生项目,它使用react原生映射和Viro。Viro需要rn 0.59.9的rn版本,所以我在这个项目中没有使用最新版本 它目前被设置为使用本地苹果地图时,使用iPhone模拟器,它工作良好,我也有Viro工作。下一步是开始从当前用户的位置向他们周围的不同地方添加方向,我计划使用谷歌地图来实现这一点 不幸的是,我在尝试做这件事时遇到了很多问题,而且在整个过程中都没有运气 My package.json当前的外观如下: { "name": "LoveWinchester

我目前有一个react原生项目,它使用react原生映射和Viro。Viro需要rn 0.59.9的rn版本,所以我在这个项目中没有使用最新版本

它目前被设置为使用本地苹果地图时,使用iPhone模拟器,它工作良好,我也有Viro工作。下一步是开始从当前用户的位置向他们周围的不同地方添加方向,我计划使用谷歌地图来实现这一点

不幸的是,我在尝试做这件事时遇到了很多问题,而且在整个过程中都没有运气

My package.json当前的外观如下:

{
  "name": "LoveWinchester",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "postinstall": "jetifier -r"
  },
  "dependencies": {
    "axios": "^0.19.0",
    "react": "16.8.3",
    "react-native": "0.59.9",
    "react-native-gesture-handler": "~1.4.0",
    "react-native-maps": "0.26.1",
    "react-native-reanimated": "^1.4.0",
    "react-native-screens": "^1.0.0-alpha.23",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^1.10.3",
    "react-viro": "2.17.0",
    "rn-bottom-drawer": "^1.4.3"
  },
  "devDependencies": {
    "@babel/core": "^7.7.2",
    "@babel/runtime": "^7.7.2",
    "babel-jest": "^24.9.0",
    "jest": "^24.9.0",
    "jetifier": "^1.6.4",
    "metro-react-native-babel-preset": "^0.57.0",
    "react-test-renderer": "16.8.3"
  },
  "jest": {
    "preset": "react-native"
  }
}
我的播客文件如下所示:

target 'LoveWinchester' do
platform :ios, '9.3'
  pod 'ViroReact', :path => '../node_modules/react-viro/ios/'
  pod 'ViroKit_static_lib', :path => '../node_modules/react-viro/ios/dist/ViroRenderer/static_lib'
  pod 'RNReanimated', :path => '../node_modules/react-native-reanimated'

  pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

  pod 'RNScreens', :path => '../node_modules/react-native-screens'

  pod 'react-native-maps', :path => '../node_modules/react-native-maps'

end
任何帮助都将不胜感激

  • 添加了谷歌地图
  • 然后转到iOS文件夹&安装它

    cd ios
    pod install
    
  • 现在,您可能会得到一个错误:必须将AirGoogleMaps目录添加到您的xCode项目中,才能在iOS上支持GoogleMaps。
  • 要解决此问题,请转到iOS文件夹并打开.xcworkspace文件,因为现在需要将AirGoogleMaps添加到项目中

    进入项目中的节点\u模块,导航到空中谷歌地图文件夹

    /node_modules/react-native-maps/lib/ios/AirGoogeMaps
    
    AirGoogleMaps文件夹拖动到项目中。将该文件夹放入项目后,将出现一个弹出窗口,您将在其中指定创建组。(不创建文件夹引用)

  • 然后进入
    xcode>build settings>Preprocessor Macros>
    &添加
    HAVE\u GOOGLE\u MAPS=1
    预处理器宏以生成设置
  • 为了使用谷歌地图,您需要创建一个
  • 然后转到AppDelegate.m&在代码中添加以下行

    #import <GoogleMaps/GoogleMaps.h>
    
    [GMSServices provideAPIKey:@"YOUR_API_KEY"]
    
    就这样。希望这对你有帮助。不要怀疑


    有关更多信息

    非常感谢您如此全面的回复!!我原以为就是这样,但不幸的是,在按照您的说明运行了
    react native run ios--simuator=“iPhone 7 Plus”
    之后,我收到了一个错误:构建ios项目失败。我们运行了“xcodebuild”命令,但它退出了,错误代码为65。您可以在此处看到包含更多详细信息的屏幕截图。我以前也曾多次尝试过同样的错误。@Madamot检查一下-不幸的是,按照链接中的步骤之后,同样的错误似乎发生了-imgur.com/a/Hypw8bb。我在错误的顶部得到警告,说React和RNScreens的IPHONEOS_部署_目标是7.0,但支持的版本是8.0到13.2.99。我不确定这是否会导致错误@SDushan@Madamot此问题存在于生成系统设置中。检查这个-
    #import <GoogleMaps/GoogleMaps.h>
    
    [GMSServices provideAPIKey:@"YOUR_API_KEY"]
    
    import MapView, {PROVIDER_GOOGLE} from "react-native-maps";
    
    <MapView provider={PROVIDER_GOOGLE} />