How to Embed Google Map in HTML: A Quick and Easy Guide for Beginners

By Cristian G. Guasch •  Updated: 09/18/23 •  10 min read

In today’s digital era, having a website that’s both user-friendly and informative is key. One way to boost your site’s functionality is by embedding a Google Map onto it. This feature not only enhances the overall experience for visitors but also gives your business an extra layer of authenticity by showcasing its physical location. So, how exactly can you add this handy tool to your HTML code? Let me walk you through the process.

First off, it’s important to note that embedding a Google Map in HTML isn’t as tricky as it sounds. In fact, Google has made this task pretty straightforward for us all. Whether you’re a novice or seasoned pro at coding, I’m confident you’ll find this tutorial helpful and easy to follow.

As we delve into the specifics, keep in mind that integrating a map into your webpage can greatly improve its SEO ranking. Search engines like Google appreciate websites with clear geographic indicators because they provide useful information for users. Plus, let’s be real – adding cool features like interactive maps will make your site stand out from the crowd! So let’s get started on enhancing your web presence today.

Understanding Google Maps and HTML Integration

Let’s dive right into the heart of this topic – integrating Google Maps with HTML. It’s not as daunting as it might seem. In fact, by using a simple piece of code provided by Google itself, you can easily embed a fully functional map on your website.

The first thing you need to do is head over to the Google Maps website. From there, pinpoint the location you’re interested in showcasing on your site. Once set, click on the ‘Share’ button and then choose ‘Embed map’. You’ll be presented with an HTML script that looks something like this:

<iframe src="!1m18!1m12!1m3!1d3153.8356373709055!2d144.96328031591252!3d-37.8136289808796!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6ad642af0f11fd81%253A0x5045675218ce6e41!2sMelbourne+VIC%252C+Australia!5e0!3m2!1sen!2sus!4v1508078861959" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

You simply copy this script and paste it into your webpage’s HTML where you want the map to appear. Like this:

What if I told you that there are variations available for embedding maps too? Let me explain how they work. You can adjust the size of your embedded map using attributes within iframe tags such as width and height. Setting these to different values will change the map’s dimensions on your webpage. You can also tweak the source URL parameters to customize your map’s view, zoom level, and more.

<iframe src="!1m18!1m12!1m3!1d3153.8356373709055!2d144.96328031591252!3d-37.
... (remaining part of URL)
width="800" height="600" frameborder="0" style="border:0" allowfullscreen></iframe>

In this example above, I’ve increased the width and height attributes to make the map appear larger on my webpage.

This is just scratching the surface of what you can do with Google Maps and HTML integration. There’s a world of possibilities out there for enhancing your website with customized maps – all it takes is a bit of code tweaking and creativity.

Steps to Generate Your Google Map Embed Code

Ever wondered how you can insert a piece of the world right into your website? Well, it’s not as complex as you might think. In fact, I’m going to show you exactly how to generate your Google Map embed code in just a few easy steps.

Firstly, you’ll need to head over to Google Maps. Once there, type in the location that you’d like to display on your webpage. It could be anything from your business’s physical address to a favorite vacation destination. The choice is all yours!

After hitting the search button and locating your desired spot on the map, look for the ‘Share’ button; it’s usually located on the left side of the page. Clicking on this will open up a dialog box with two options: “Send a link” or “Embed map”. You’ll want to go ahead and click ‘Embed map’.

Next comes choosing the size of your embedded map. Google Maps offers several standard sizes (small, medium, large), but also allows for custom dimensions if none of these fit what you’re looking for.

Once you’ve selected an appropriate size for your site layout, all that’s left is copying and pasting! Right below where you chose your size option will be an iframe tag containing your unique embed code.

Here’s an example:

<iframe src="!1m18!1m12!1m3!1d3151.8354345095778!2d144.95373531531643!3d-37.
8152069797516" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>

In this example above width is set at “600” and height at “450”, but feel free adjust those numbers to meet your specific needs. Just remember to maintain the rest of the code as it is, including any quotation marks or punctuation.

And there you have it! You’ve successfully generated your Google Map embed code. With a quick copy and paste, you’re ready to bring a piece of the world into your website. It’s that simple. Now, go forth and map-ify your web content like never before!

Embedding the Google Map Code in Your HTML Page

I’m going to walk you through how to embed a Google Map into your HTML page. It’s a straightforward process, and with just a few lines of code, you can feature any location on your website.

Let’s start by finding the map you want to embed. Head over to Google Maps, type in the address or location, and click on ‘Share’. A pop-up will appear; select ‘Embed map’, then choose your preferred size. I generally go for ‘Medium’, but it’ll depend on your layout. After deciding on the size, copy the iframe code that appears.

Now comes the exciting part: embedding this into your HTML page. Open up your HTML file in any text editor (Notepad++, Sublime Text, Atom – take your pick!). Find where you’d like to place this map within your site structure. Paste the copied iframe tag directly into this section of code.

Here’s an example:

<!DOCTYPE html>
<title>Page Title</title>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

<!-- Here is where we insert our Google Maps iframe -->
<iframe src="!1m18!1m12!1m3!1d95780.66762223154!2d2.057788381430265!3d41.39263855812282!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x12a49816718e30e5%3A0x44b0fb3d4f47660a!2sBarcelona!5e0!3m2!1ses!2ses!4v1695053768910!5m2!1ses!2ses" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>


Notice how there isn’t any extra work involved after pasting? That’s because iframes are self-contained; they don’t require closing tags within themselves.

You might wonder what happens if you need multiple maps? The answer is simple – repeat these steps for each location and paste each corresponding iframe tag where needed in your HTML file.

To add some flair or functionality beyond what Google provides by default, you can use Google Maps APIs. However, that’s a topic for another day. For now, you’re all set to show off your new map-embedded site!

Troubleshooting Common Issues with Google Map Embedding

Embedding a Google map into your HTML code may look simple, but it’s not uncommon to run into issues. I’ve encountered several problems myself and thought sharing some troubleshooting tips might be helpful.

Perhaps the most common issue is getting an error message like “This page didn’t load Google Maps correctly.” Now, don’t panic. This typically means there’s something wrong with your API key or billing account. Double-check if you’ve entered the correct API key in your HTML code. If that doesn’t work, head over to the Google Cloud Console and ensure that your billing information is up-to-date.

Let’s say you’ve done all this, but there’s still no map showing up on your webpage. It could be a problem with your iframe syntax. Take a closer look at how you’ve embedded the map:

<iframe src=";output=embed"></iframe>

In this example, replace "place_name" with the location name or coordinates you want to display on the map. But remember, if the place name includes spaces, make sure to replace them with %20. Also, check for any missing quotation marks or closing tags – they can easily slip under our radar!

Some of you might also face issues when trying to customize embedded maps using CSS stylesheets directly within HTML documents (inline styles). Unfortunately, inline styles won’t work as Google Maps overrides them by default. Instead of:

<div id="map" style="height:400px; width:500px;"></div>

Use JavaScript customization options provided by Google Maps API more effectively:

function initMap() { 
  var uluru = {lat: -25.344, lng: 131.036}; 
  var map = new google.maps.Map( 
      document.getElementById('map'), {zoom: 4, center: uluru}); 
  var marker = new google.maps.Marker({position: uluru, map: map}); 

And there you have it! These are a few common issues people often encounter when embedding Google Maps into HTML. I hope these tips help you in your web development journey. Remember to always check your code for any syntax errors – they’re usually the culprits behind most problems. Happy coding!

Conclusion: Harnessing Google Maps for Better Web Navigation

Embedding Google Maps in HTML isn’t just a technical feat, it’s a practical move to enhance web navigation. I’ve shown you the ropes, and now, you’re ready to offer your website visitors an interactive mapping feature.

Let’s do a quick recap:

Here are some sample codes again for clarity:

<iframe src="" width="600" height="450"></iframe>
   iframe {
      max-width: 100%;

There’s still plenty of room for experimentation though! You might want to try adding markers or drawing routes on your embedded maps next.

No doubt about it – integrating Google Maps into your HTML not only advances your coding skills but also significantly benefits end users. They get to visualize locations better and navigate easier around your site.

Harnessing Google Maps is indeed stepping up web development game plan!

Cristian G. Guasch

Hey! I'm Cristian Gonzalez, I created HTML Easy to help you learn HTML easily and fast.

Related articles