How can I create a responsive iframe in Webflow for embedding a Google MyMaps map?
To create a responsive iframe in Webflow for embedding a Google MyMaps map, you will need to follow these steps:
Start by going to your Google MyMaps account and select the map you want to embed.
In Google MyMaps, click on the Share button located at the top-right corner of the page.
In the Share dialog box, click on the Embed map tab.
Copy the iframe embed code provided by Google MyMaps.
Now, go to your Webflow project and open the page where you want to embed the map.
Drag an Embed element from the Elements panel onto the desired location on your page.
Double-click on the Embed element and paste the Google MyMaps iframe code you copied earlier.
Click outside the element to apply the changes.
To ensure that the embedded map is responsive, you need to add some custom code to your Webflow project.
Go to the Custom Code section in your Project Settings.
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%;}
Save the changes and go back to your page.
Select the Embed element and give it a class name, for example, "embed-map".
Return to the Designer, and in the Styles panel, click on the "+" button to create a new rule.
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%); }}
- 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:
- How do I embed a Google MyMaps map in Webflow?
- What is the best way to make an iframe responsive in Webflow?
- Can I customize the appearance of the embedded Google MyMaps map in Webflow?