How to Make the New Google Maps Embeds Responsive
The new Google Maps now offer you can option to embed maps in your web pages. While you are on the Google Maps website, zoom-in to an area that you wish to embed, click the Gear icon in the lower left corner and choose the Embed Maps option from the menu.
This web page contains a sample map embedded using the default embed code provided by Google Maps. The embedded map is non-responsive. What it means is if you open the page on a device other than your desktop computer, the Google Map won’t fit the screen and you’ll have to scroll the page horizontally to see the complete map.
Here’s another web page that contains the same Google Map but now the map has been embedded responsively. Thus, if you resize the browser or view the page on a small device, the embedded map would adjust its size automatically based on your screen size.
How to Embed Google Maps Responsively
This is the default embed code for the new Google Maps:
1.
2.
As specified in the height and width parameters of the embed code, the default height for medium embeds is 450px or 75% of the default width (600px).
If you wish to transform this static sized Google Map into one that is responsive, all you have to do is add a few CSS rules to your web page and wrap the embed IFRAME inside these rules.
The new embed code with responsive style will be something like this. You can change the value of padding-bottom (line #4) from 75% to something for a different aspect ratio.
1.
16.
17.
18.
19.
A similar technique can be used to embed Instagram videos and photos responsively
0 comments:
Post a Comment