How can I create a responsive iframe in Webflow for embedding a Google MyMaps map?

Published on
September 22, 2023

To create a responsive iframe in Webflow for embedding a Google MyMaps map, you will need to follow these steps:

  1. Start by going to your Google MyMaps account and select the map you want to embed.

  2. In Google MyMaps, click on the Share button located at the top-right corner of the page.

  3. In the Share dialog box, click on the Embed map tab.

  4. Copy the iframe embed code provided by Google MyMaps.

  5. Now, go to your Webflow project and open the page where you want to embed the map.

  6. Drag an Embed element from the Elements panel onto the desired location on your page.

  7. Double-click on the Embed element and paste the Google MyMaps iframe code you copied earlier.

  8. Click outside the element to apply the changes.

  9. To ensure that the embedded map is responsive, you need to add some custom code to your Webflow project.

  10. Go to the Custom Code section in your Project Settings.

  11. In the Head Code section, paste the following CSS code:

.embed-container {  position: relative;  padding-bottom: 70%;  height: 0;  overflow: hidden;}.embed-container iframe {  position: absolute;  top: 0;  left: 0;  width: 100%;  height: 100%;}
  1. Save the changes and go back to your page.

  2. Select the Embed element and give it a class name, for example, "embed-map".

  3. Return to the Designer, and in the Styles panel, click on the "+" button to create a new rule.

  4. Add the following CSS code to the new rule:

.embed-map {  max-width: 100%;}@media (max-width: 767px) {  .embed-map {    width: 100vw;    margin-left: calc(-50vw + 50%);    margin-right: calc(-50vw + 50%);  }}
  1. Publishing your site will ensure that the changes take effect.

Now, your Google MyMaps map is embedded in a responsive iframe on your Webflow site. The map will automatically adjust its size based on the device or viewport it is viewed on.

Additional Questions:

  1. How do I embed a Google MyMaps map in Webflow?
  2. What is the best way to make an iframe responsive in Webflow?
  3. Can I customize the appearance of the embedded Google MyMaps map in Webflow?