This tutorial provides the steps to embed responsive maps in Oxygen using Google’s Maps Embed API.

Step 1

Visit the Google maps embed API quickstart page.

Follow the steps listed there to obtain an API key.

Step 2

Enter your desired address or the search term or any other option available under “I want to…” and generate the iframe code.

Paste your API key and press Done to get the iframe code similar to:

<iframe width="600" height="450" style="border:0" loading="lazy" allowfullscreen src="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJcw5BAI63t4kRj5qZY1MSyAo&key=xxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxx"></iframe>

Step 3

Add a Code Block component in Oxygen builder.

Set its width to 100%.

If you do not want the map to take up the full width of the container, set the max-width to something like 500px.

Paste the iframe code in the PHP & HTML section but without the

width="600" height="450" style="border:0"

part.

Also, wrap the code between

<div class="iframe-container">

and

</div>

Ex.:

<div class="iframe-container"><iframe loading="lazy" allowfullscreen src="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJcw5BAI63t4kRj5qZY1MSyAo&key=xxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxx"></iframe></div>

Step 4

At Manage > Stylesheets, add the following CSS:

/* Responsive iframes */

:root {
	--aspect-ratio: 16/9;
}

.iframe-container {
	position: relative;
	width: 100%;
	margin-bottom: 40px;
}

.iframe-container::before {
	content: "";
	display: block;
	padding-bottom: calc(100% / (var(--aspect-ratio)));
}

.iframe-container iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

Reference

https://wpdevdesign.com/responsive-vadootv-player-and-iframes/

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

You need to be logged in to view and post comments.
Not a member yet? Join here.
magnifiercross
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: