How to Embed Google Map in HTML [Step-By-Step Guide] (2024)

Want to know how to embed a Google Map in HTML for your website? You’ve found the right blog post.

How to Embed Google Map in HTML [Step-By-Step Guide] (1)

With tens of millions of daily users, Google Maps is by far the leading navigation and maps platform on the web. There are many ways you could implement a map on your website. For instance, you could display the location(s) of your brick-and-mortar business so users can get directions.

A well-placed map gives users some extra help and improves the overall experience of your site, which is why Google Maps makes it pretty easy to embed its maps. In this guide, we’ll show you how to make both static maps and responsive maps, and then place them on your website.

How to Embed a Google Map in HTML

Embedding a static Google map on your website boils down to finding your address, copying the embed code, and pasting the code into your HTML. Note that these maps, while interactive, are somewhat basic.

For more complex capabilities such as directions and displaying location data, you need to access the Google Maps API.

We're committed to your privacy. HubSpot uses the information you provide to us to contact you about our relevant content, products, and services. You may unsubscribe from these communications at any time. For more information, check out our Privacy Policy.

How to Embed Google Map in HTML [Step-By-Step Guide] (3)

50 Free Coding Templates

Free code snippet templates for HTML, CSS, and JavaScript -- Plus access to GitHub.

  • Navigation Menus & Breadcrumbs Templates
  • Button Transition Templates
  • CSS Effects Templates
  • And more!

Loading your download form

You're all set!

Click this link to access this resource at any time.

Download Now

Learn more

But for a simple Google map, here’s the easiest method:

1. Go to the Google Maps website.

2. Search for the location you want to feature in your embedded map.

3. Click Share. Alternatively, you can click the three horizontal lines in the top left corner and choose Share or embed map from the menu that appears.

How to Embed Google Map in HTML [Step-By-Step Guide] (4)

4. Click Embed a map to see a preview of the embed. Here, you can toggle the map area, zoom, type (street map or satellite map), and size (including a custom size if you’d like)

How to Embed Google Map in HTML [Step-By-Step Guide] (5)

5. When ready to embed, click Copy HTML.

6. In your HTML file, paste the embed code where you want the map to appear on the page. The code will look something like this (it may look different depending on the size your chose for your map:

<iframe src="[your unique google URL] " width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>

7. Save the HTML file and open the file in a web browser to view the map in action.

Here’s what our example looks like embedded on a page:

See the Pen google maps in HTML by HubSpot (@hubspot) on CodePen.

At this point, the embedded map is static — it will retain a width of 600 pixels and a height of 400 pixels, no matter what device it’s displayed on or the size of the browser window.

However, this doesn’t make for the best user experience, since many visitors, especially those on mobile devices, won’t be able to see the entire map on their screen at once. They’ll need to scroll vertically and/or horizontally to view the map.

To solve this problem, we can make our embedded map responsive with a bit of extra HTML and CSS.

How to Make a Responsive Google Map in HTML

It’s widely considered a best practice to make your pages responsive, meaning all elements rearrange and change their size to fit on their screens.

The default Google Maps embed code is not responsive, but we don’t need to change much in the code to make the map scale up or down in response to the size of the viewport.

To make a responsive Google Map in HTML, take your existing embed code and place it in your HTML document. Then, wrap the <iframe> element (which represents the map) in a container <div> with the class google-map.

<div class="google-map"> <iframe src="[your unique google URL] " width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe></div>

Next, in your CSS, add the following code:

.google-map { padding-bottom: 50%; position: relative;}.google-map iframe { height: 100%; width: 100%; left: 0; top: 0; position: absolute;}

Here’s the result. The map will scale proportionally to the size of your browser.

See the Pen google maps in HTML: responsive by HubSpot (@hubspot) on CodePen.

In the CSS, the padding-bottom property is what sets the height of the map. You can change the height by changing the percentage value of padding-bottom.

Embed a Google map, the easy way.

By following the above steps, even a novice site owner can place a basic or responsive Google map onto a website. They’re great for “about” or “contact” pages, and provide visitors with a bit more context about your business, meaning a greater chance of conversion.

If you’re just getting started with HTML and want to learn more, be sure to check out our free guide to HTML and CSS, linked below.

Topics: HTML

How to Embed Google Map in HTML [Step-By-Step Guide] (2024)

FAQs

How to Embed Google Map in HTML [Step-By-Step Guide]? ›

In the google map link that you have mentioned above, open it and click on Menu bar. Choose Share or embed map and you may find your html code for website.

How to embed a Google Map in HTML? ›

In the google map link that you have mentioned above, open it and click on Menu bar. Choose Share or embed map and you may find your html code for website.

How to add Google Map inside HTML page without using API key? ›

Example
  1. Step 1 − Go to the Google Maps website and search for the location you want to display on your map −
  2. Step 2 − Click on the share button and then click on the "Embed map" tab −
  3. Step 3 − Copy the iframe code provided −
  4. Step 4 − Paste the iframe code into your HTML (index.
Feb 2, 2023

How do I align Google Maps in HTML? ›

Try using <p style="width: 48%; float: left;"> to wrap the HTML for your text and <p style="width: 48%; float: right;"> to wrap the HTML for your Google Map; just update the style attribute on the existing HTML tags (using these to replace text-align: justify , which is there now).

Can I embed Google map in my website for free? ›

All Maps Embed API requests are available at no charge with unlimited usage.

Do I need an API key to embed a Google map? ›

You must include an API key with every Maps Embed API request.

What does "embed a map" mean? ›

Embedding a Google Map into a personal website or blog is a simple way to help visitors navigate an area or easily find directions to a location. Google Maps has a "Share or embed map" feature that provides users with the map's HTML code so that they can insert it into their website's code.

How to add a map in HTML using Bootstrap? ›

Bootstrap 5 Google maps component
  1. In your browser, go to Google Maps and enter the address you want to be visible on the map.
  2. Click the "Share" button.
  3. A new window will pop up. Click on the "Embed a map" tab and copy the provided HTML.
  4. Paste the copied HTML.

How do I overlay a Google Map? ›

Use an image as an overlay
  1. Open Google Earth Pro.
  2. Position the 3D viewer in the location where you want to set the overlay image. ...
  3. Click Add. ...
  4. Enter a name.
  5. Upload an image: ...
  6. Enter a description.
  7. Click Refresh to set the refresh properties for your overlay image. ...
  8. Use the slider to set the default transparency for the image.

Can we embed Google map in HTML? ›

To make a responsive Google Map in HTML, take your existing embed code and place it in your HTML document. Then, wrap the <iframe> element (which represents the map) in a container <div> with the class google-map.

How do I embed a Google map into an HTML email? ›

Your best bet is to get a static image of the map and embed it as an image in an HTML email. Put a hyperlink on it to the "full" map on Google Maps. To do this manually in Gmail: Go to http://staticmapmaker.com/google/ or similar.

How do I add multiple locations to Google Maps HTML? ›

Add a place
  1. On your computer, sign in to My Maps.
  2. Open or create a map. A map can have up to 10,000 lines, shapes, or places.
  3. Click Add marker .
  4. Select a layer and click where to put the place. A layer can have 2,000 lines, shapes, or places.
  5. Give your place a name.
  6. Click Save.

How do I embed a google form in HTML? ›

  1. Open a form in Google Forms.
  2. In the top right, click Send.
  3. At the top of the window, click Embed .
  4. To copy the HTML that appears, click Copy or press Ctrl + c (Windows) or ⌘ + c (Mac) on your keyboard.
  5. Paste the HTML into your website or blog.

Is embedding Google Maps free? ›

Costs. All Maps Embed API requests are available at no charge with unlimited usage.

How do I embed HTML into google site? ›

Insert HTML, JS & CSS - Embed Code
  1. On the Insert panel use the Embed option.
  2. Choose the EMBED CODE tab.
  3. Type or paste the custom HTML, JavaScript and CSS into the code box.
  4. Use the NEXT button to preview how your code will look.
  5. Use the INSERT button to add the code to the page.

Top Articles
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 5571

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.