Add or Embed a Google Map Location on a React App

When building a business or portfolio website, we are sometimes required to embed the Google Map location. This makes our customers easily spot our business. Here we will discuss the steps to add or embed a Google Map location on a React app.


The reader should be aware of the following technologies:-

What we will learn

After completing this article, we will learn to create a new React application using the create-react-app tool and we will add or embed the Google Map in it.

The steps are explained below:-

  • Create a new React app
  • Search for the term “Apple headquarters” in Google Map.
  • Click on the share button, Embed a map button, and copy the iframe section.
  • Convert the style tag to React compatible.
  • Paste the code on App.js on our React app.

The application will look the same as below after coding.

Add Google Map Location on a React App

If you are interested in following a video guide, go ahead with the youtube video below.

Others, please follow the below steps.

We can first create a new React project and then add the Google map to it.

Create a new React project

The first step is setting up a React application on your system. This can be easily done using the NPX tool.

So, install Node.js on your system first and create a react application using NPX. Don’t bother about the term NPX, because it’s a tool coming with NPM(Node Package Manager) 5.2+ onwards which will install on your system with Node.js itself.

If you need further assistance in the installation of React on your system, use the below links.

Install React on WindowsUbuntu, and macOS

npx create-react-app googlemap-react-demo-app

This command will create a react application with the project name googlemap-react-demo-app

Now enter the project directory and start the app.

cd googlemap-react-demo-app
npm start

It will open up the React application we have created in our browser window with the address https://localhost:3000. The port may vary if 3000 is busy.

Now we can use our favorite code editor to edit our project. I personally recommend Visual Studio Code.

Copy the HTML from Google map to embed

Now let us copy the HTML to embed from Google Map. This can get in simple steps.

Search for the location on Google map click the Share button

Access the Google map website and search for the location to be embedded on our website. If we are building a business website, we need to search for the business location.

So click on the Google map URL below and search for your business location.

Here we are searching for the term “apple headquarters”. This will give the map of the app Apple Park in Cupertino. We can also adjust the zoom from here.

Now click on the share button.

Click on Embed a map tab and copy the HTML

We will get the Share modal and click on the Embed a map tab from the top and the Copy HTML button.

Add the copied HTML to our React app

This will copy the iframe HTML to the clipboard. Now paste it on the App.js file in our React app.


We need to change the style property like below. Because in React, it is the structure.

style={{ border: "0" }}

So that the code will be like below.

import "./App.css";

function App() {
  return (
    <div className="App">
        style={{ border: "0" }}

export default App;

The file structure and code will look as below.

In the browser, we can see that a map is rendered on our app with the location we have chosen before.


Refer to the CodeSandbox link to view the live app. You can also clone this project to your CodeSandbox account and edit the code.


You can always refer to the GitHub repository to clone this project, refer to the code and work on top of it.


So in this article, we discussed the steps to add or embed Google map location on a React app.

3 thoughts on “Add or Embed a Google Map Location on a React App

  1. Hi Syamlal!
    Thank you so much for composing this article. It was just the right solution I needed. Keep up the good work!

  2. Please how can I make the location dynamic, can I pass a dynamic location to the URL
    eg `https://xxxxxxxxxx${property.location}……`

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.