Sizing and responsive iframes

Fixed size, full width with an aspect ratio, or a minimum height in a flex column.

Live map

width: 100%; aspect-ratio: 16 / 9Open this map on its own
width: 100%; aspect-ratio: 1Open this map on its own

Code

HTML
<iframe
  class="map-embed"
  src="https://maps.siemens-cdn.com/maps/embed/v1/place?q=52.53750,13.26330&zoom=14"
  title="Siemensstadt Berlin, 16 by 9"
  loading="lazy"
  referrerpolicy="no-referrer-when-downgrade"></iframe>
CSS
/* Full width, height from the aspect ratio */
.map-embed {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

/* Or: fill a flex column, but never shorter than 300px */
@media (min-width: 768px) {
  .map-col .map-embed {
    aspect-ratio: auto;
    height: 100%;
    min-height: 300px;
  }
}

Every map follows the visitor’s light or dark setting by default (colorScheme=auto). On these pages it follows the docs theme switch too.

Every parameter: embed URL reference.

Migrating from Google

Only the src line changes: the host becomes https://maps.siemens-cdn.com and key goes. Every other attribute and parameter stays identical. Then swap www.google.com for https://maps.siemens-cdn.com in your page’s frame-src, in the enforced and in the report-only policy. Full migration guide.

iframe before and after, width: 100%; aspect-ratio: 16 / 9
  <iframeRemoved: -   src="https://www.google.com/maps/embed/v1/place?key=API_KEY&q=52.53750,13.26330&zoom=14"Added: +   src="https://maps.siemens-cdn.com/maps/embed/v1/place?q=52.53750,13.26330&zoom=14"    title="Siemensstadt Berlin, 16 by 9"    width="600"    height="450"    style="border:0"    loading="lazy"    allowfullscreen    referrerpolicy="no-referrer-when-downgrade"></iframe>
Response header of your page
Removed: - Content-Security-Policy: default-src 'self'; frame-src 'self' https://www.google.comRemoved: - Content-Security-Policy-Report-Only: default-src 'self'; frame-src 'self' https://www.google.comAdded: + Content-Security-Policy: default-src 'self'; frame-src 'self' https://maps.siemens-cdn.comAdded: + Content-Security-Policy-Report-Only: default-src 'self'; frame-src 'self' https://maps.siemens-cdn.com

Notes

  • The map fills whatever box the iframe gets and redraws when it is resized. Give the iframe a height: an iframe with neither height nor aspect ratio is 150 px tall.
  • Keep at least about 250 px of height so the zoom buttons and the attribution do not overlap.
  • The © OpenStreetMap attribution must stay visible (ODbL). Do not cover or crop it.