by Mukhamed Khasanza
由Mukhamed Khasanza
如何使用react-native-maps将地图集成到React Native中 (How to integrate maps in React Native using react-native-maps)
Nowadays, almost all mobile applications have a maps feature. I had to integrate Google Maps to my React Native application, and the only choice was react-native-maps by Airbnb (it’s the only one still supported by the React Native community).
如今,几乎所有移动应用程序都具有地图功能。 我必须将Google Maps集成到我的React Native应用程序中,唯一的选择是Airbnb的react-native-maps(这是React Native社区唯一仍支持的地图)。
I found several tutorials on how to set up this library, but none fully worked for me. This was because I had to run on both iOS and Android platforms and also support Google Maps for iOS.
我找到了一些有关如何设置该库的教程,但没有一个对我完全有用。 这是因为我必须同时在iOS和Android平台上运行,并且还必须支持iOS版Google Maps。
Let’s create a React Native application from scratch using react-native-cli to show, step by step, how everything is installed. If you want to integrate react-native-maps for your existing app, skip Step 1.
让我们使用react-native-cli从头开始创建一个React Native应用程序,以逐步展示所有安装方式。 如果要为现有应用程序集成react-native-maps,请跳过步骤1 。
步骤1:安装和设置React Native应用程序 (Step 1: Install and set up React Native application)
If you haven’t installed the React Native command line interface, run: npm install -g react-native-cli
. Now you can create your project, simply using: react-native init ReactNativeMaps
如果尚未安装React Native命令行界面,请运行: npm install -g react-native-cli
。 现在,您只需使用以下命令即可创建您的项目: react-native init ReactNativeMaps
Here are the dependency versions at the time of building this project:
以下是构建此项目时的依赖项版本:
- “react”: “16.6.1” “React”:“ 16.6.1”
- “react-native”: “0.57.5” “本机”:“ 0.57.5”
- “r