React Native Integrate Google Maps in Android iOS App Example Tutorial

Google maps is web mapping service developed by Google. Google launched the Google maps free service on 8 February 2005. Since then it is became continuously popular among regular peoples and mobile application developer. In react native we can easily Integrate Google Maps in Android iOS application using react-native-maps NPM GitHub library. react-native-maps library is popular between developers and it has more than 60 thousands download weekly. So now we know how much Google Maps is used by react native developers in their applications. In this tutorial we would learn about Authenticating Google Maps API key in react native app and show user shop or company location by a red dot Marker using Latitude and longitude. So let’s get started .

Contents in this project React Native Integrate Google Maps in Android iOS App Example Tutorial:

1. Open your react native project folder in command prompt and execute below command to install the react-native-maps library in your current react native project. If you are using windows then make sure run the Command prompt as Run as Administrator mode.

Screenshot of CMD:


2. After executing above command we need to run the
reactnative link command to refresh our current react native project and index the newly installed library file in our project. This command would automatically add all the important dependencies line in your project automatically by editing all your files.

3. If you still face any installation issue then you can read its official installation documentation Here. But there is no need to worry because i have used the link command it would automatically implement all the required changes in my react native project. We need to edit the AppDelegate.m file in iOS to implement Google Maps so read the documentation here.

4. Generate the Google Authentication API Key From Google Developers Console:

1. If we wish to use the Google Maps in our application then we need to get the Google Maps API key from Google developers console. So Open Google Developer Console link in your web browser and log-in with your Google gmail account. Now we need to create a new project for use Google Maps. So create new project and enter your project name. The name can be anything but it must be unique. Then hit the Create button.

2. Select your newly created project from upper selecting drop down window -> Credentials -> Create Credentials.

3. Now select API key under Create Credentials drop down menu.

4. You’ll see a pop up dialog saying API key created. Copy the API key at someplace else because it will be used further in our project.

5. Now we need to Enable the Maps SDK for Android. To enable Select the Hamburger Icon present at the left side of screen -> Google Maps -> Overview. Sometimes the Google Maps is not present there so simply search on the search bar .

6. Select the Maps SDK for Android .

7. Enable the Maps SDK by pressing the Enable button.

Here you go now after enabling the Maps SDK for android. Your project is ready to use the Google maps in your react native project. Its time to start coding .

5. Goto Your_React_Native_Project -> android -> app -> src -> main -> AndroidManifest.xml file. Add below meta data with Google Maps API key you have copied earlier.

Source code of my AndroidManifest.xml file:

6. Now its time to start coding. So Open your project’s App.js file and import StyleSheet & View component.

7. Import MapView & Marker component from react-native-maps library.

  • MapView : Used to show the MapView component in your project.
  • Marker : Used to show the Red round market to pinpoint the exact location on Google Maps.

8. Create MapView component in render’s return block in a Root View. Inside the MapView we would make a Marker component to pinpoint a specific location.

9. Creating Style.

10. Complete source code for App.js file class.

Screenshots:

Integrate Google Maps in Android iOS App