Mapsopenstreetmap.org
Can you embed OpenStreetMap in an iframe?
Yes, with the HTML code from the Share panel. The OpenStreetMap wiki documents the export/embed.html URL for iframes, not the main map page.
Checked Test again
Live check
Two links, two results
Map pagePartial
www.openstreetmap.org- X-Frame-Options
- SAMEORIGIN (ignored)
- CSP frame-ancestors
- 'self'
- Response
- 200 OK · 393 ms · HTTPS
Embed URLEmbeddable
www.openstreetmap.org/export/embed.html?bbox=-0.1357%2C51.4974%2C-0.1157%2C51.5066&layer=mapnik- X-Frame-Options
- Not sent
- CSP frame-ancestors
- Not sent
- Response
- 200 OK · 358 ms · HTTPS
Steps
How to embed OpenStreetMap
- Open openstreetmap.org and move the map to the area you want.
- Click the Share button at the side of the map.
- To show a pin, select Include marker. Then move the marker.
- Under Link or HTML, clickHTML
- Copy the code from the Output box. It starts with <iframe>.
- Paste the code into the HTML of your page.
Embed code
Paste this into your page
HTML
<iframe
width="425"
height="350"
src="https://www.openstreetmap.org/export/embed.html?bbox={west},{south},{east},{north}&layer=mapnik&marker={lat},{lon}"
style="border: 1px solid black"
title="{map title}">
</iframe>
<br/><small><a href="https://www.openstreetmap.org/#map={zoom}/{lat}/{lon}">View Larger Map</a></small>Remove the marker parameter when you do not want a pin. The bbox sets the area that the map shows.
URL patterns
Swap the link you have for the embed URL
- You havehttps://www.openstreetmap.org/#map={zoom}/{lat}/{lon}Use in the iframehttps://www.openstreetmap.org/export/embed.html?bbox={west},{south},{east},{north}&layer=mapnik
The Share panel makes the bbox from the map area that you see.
Good to know
- The embed shows a map that visitors can move and zoom.
- To show more than one marker, use your own map library.
- Use OpenStreetMap data only as the OpenStreetMap license allows.
Sources
- OpenStreetMap Wiki · Exportwiki.openstreetmap.org/wiki/Export
- OpenStreetMap Wiki · Deploying your own Slippy Mapwiki.openstreetmap.org/wiki/Deploying_your_own_Slippy_Map
- openstreetmap-website · leaflet.share.jsgithub.com/openstreetmap/openstreetmap-website/blob/master/app/assets/javascripts/leaflet.share.js
- MDN · X-Frame-Optionsdeveloper.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options
- iframecheck live check · both links
Profile updated