Create a Map with Google Map Api using React-Native
Last Updated :
22 Mar, 2024
In this project, we'll explore how to integrate Google Maps into a React Native application. We'll create a dynamic map that allows users to view their current location and interact with markers on the map. This project aims to provide a practical guide for developers looking to incorporate maps into their mobile applications using React Native.
Output Preview: Let us have a look at how the final output will look like

Prerequisites / Technologies used:
Approach to create Map Application:
- Our approach involves using the react-native-maps library, which provides components for integrating Google Maps into React Native applications. Key functionalities of our map include:
- Displaying the user's current location on the map.
- Adding custom markers to specific locations on the map.
- Dynamically updating the map based on user interactions.
Project Structure:

package.json:
"dependencies": {
"react-native-maps": "1.10.0",
"@expo/vector-icons": "^14.0.0",
"react-native-paper": "4.9.2"
}
Steps to Create the React-Native App:
Step 1. Set up a new React Native project:
Use Expo CLI or React Native CLI to create a new project. For Expo CLI, you can use the following command:
expo init MyMapProject
For React Native CLI, you can use:
npx react-native init MyMapProject
Step 2. Navigate to the project directory:
Once the project is created, navigate to the project directory in your terminal:
cd MyMapProject
Step 3. Install the required dependencies:
Install the necessary dependencies for integrating Google Maps into your React Native project:
npm install react-native-maps @react-native-community/geolocation
Step 4. Write the HomeScreen component:
Create another component file, HomeScreen.js, where you'll use the Map component and define the initial region for the map.
JavaScript
import React from 'react';
import { SafeAreaView } from 'react-native';
import Map from './Map';
const HomeScreen = () => {
const initialRegion = {
latitude: 37.78825, // Initial latitude
longitude: -122.4324, // Initial longitude
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
};
return (
<SafeAreaView style={{ flex: 1 }}>
<Map initialRegion={initialRegion} />
</SafeAreaView>
);
};
export default HomeScreen;
JavaScript
//Map.js
import React from 'react';
import {
View,
StyleSheet
} from 'react-native';
import MapView,
{
Marker
} from 'react-native-maps';
const Map = ({ initialRegion }) => {
return (
<View style={styles.container}>
<MapView
style={styles.map}
initialRegion={initialRegion}>
<Marker
coordinate={{
latitude: initialRegion.latitude,
longitude: initialRegion.longitude,
}}
title="Your Location"
/>
</MapView>
</View>
);
};
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
...StyleSheet.absoluteFillObject,
},
});
export default Map;
JavaScript
import React from 'react';
import HomeScreen
from './components/HomeScreen';
const App = () => {
return <HomeScreen />;
};
export default App;
Step 5. Run the application:
Ensure that you have either an Android emulator or iOS simulator set up on your machine. Then, run the following command to start the application:
npx react-native run-android
or
npx react-native run-ios
Output:

Similar Reads
Create a Weather App with Forecast using React-Native React-Native is an open-source framework used to develop cross-platform applications i.e., you can write code in React-Native and publish it as an Android or IOS app. In this article, we will build a weather app using React-Native. The app contains two features:Getting the current weather of a given
5 min read
Create a Dashboard App using React-Native A dashboard app using react native is a software application designed to provide a consolidated and visual representation of important information, data, or features in a single, easily accessible interface. Dashboards are commonly used in various industries to help users monitor, analyze, and manag
7 min read
Create Memes Generator App using React-Native The MeÂme Generator App is a mobile application that allows users to effortlessly create memes. With its useÂr-friendly interface, useÂrs can choose from a wide collection of popular meÂme templates and add their own customized text to the top and bottom. In this article, we will see how we can bui
4 min read
Create a GPA Calculator using React Native A GPA calculator proves to be a useful tool for students who want to monitor their academic progress. In this article, we will build a GPA calculator using React Native, a popular framework for building mobile applications. To give you a better idea of what weâre going to create, letâs watch a demo
15+ min read
Create a Location Sharing App using React-Native In this article, we are going to build a step-by-step Location Sharing App using React-Native. A Location Sharing App developed with React-Native allows users to share their real-time location with others. It leverages React-Native's cross-platform capabilities to create a mobile application that fa
4 min read
Create Job Board App using React-Native In this article, we are going to create a Job Board App using React Native. The Job Board App is a simple application that is a collection of job openings in any field. It helps students and those searching for jobs in the market. It helps to find jobs and provides in-depth information related to ap
7 min read