简体   繁体   English

如何在 React Native 中实现 Google Maps 以在 Web、Andriod 和 iOS 上工作?

[英]How do I implement Google Maps to work on Web, Andriod and iOS in React Native?

I am fairly new to React Native and I am trying to implement a map that can be used in Web, Android and iOS.我是 React Native 的新手,我正在尝试实现一个可以在 Web、Android 和 iOS 中使用的地图。

The resources I have found online, are for implementing Android and iOS with react-native-maps or just in Web with react-native-web-maps.我在网上找到的资源用于使用 react-native-maps 或仅在 Web 中使用 react-native-web-maps 实现 Android 和 iOS。 Is there an easy way to incorporate all of them in React Native?有没有一种简单的方法可以将所有这些都合并到 React Native 中?

I am also using the Expo CLI to run the server.我还使用 Expo CLI 来运行服务器。 I have not run npm run eject to create the OS-specific files as I am trying to make the code as cross-platform as possible.我没有运行npm run eject来创建特定于操作系统的文件,因为我试图使代码尽可能跨平台。

I don't know if any package works straight away for all environments but you can conditionally render map component for mobile and for web.我不知道是否有任何包可以立即适用于所有环境,但您可以有条件地为移动设备和 Web 渲染地图组件。

I have used these following packages in mobile and web versions of Expo app, they work pretty similarly and are easy to use and implement:我在 Expo 应用程序的移动和网络版本中使用了以下这些软件包,它们的工作原理非常相似,并且易于使用和实现:
-mobile: @react-navigation/native -移动: @react-navigation/native
-web: @react-google-maps/api -web: @react-google-maps/api

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM