Embed Google Map

2022-Jul-18

Home

email Feedback About This Page

google.com: Share a map or directions with others

Embed a map or directions
  1. Open Google Maps.
  2. Go to the directions, map, or Street View image you'd like to embed.
  3. In the top left, click Menu or .
  4. Click Share or embed map.
  5. Click Embed map.
  6. To the left of the text box, pick the size you want by clicking the Down arrow.
  7. Copy the text in the box.
  8. Paste in your web page.

To have the map have responsive style:
Can change padding-bottom (line #4) from 75% to something else for a different aspect ratio.

How to Embed Google Maps in your Website Responsively and Lazily 2022-Feb-01

/* the css */
.google-maps {
    position: relative;
    padding-bottom: 75%; // This is the aspect ratio
    height: 0;
    overflow: hidden;
}

.google-maps iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}


the html:
<div class="google-maps">
    <iframe
        src="https://www.google.com/maps/embed"
        width="600"
        height="450"
        style="border:0;"
        allowfullscreen=""
        loading="lazy">
    </iframe>
</div>