You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide support for iframe-embeddable OHM maps #485
#433 tracks the static version of this request, which doesn’t seem like a big effort at a glance, but an embedded interactive map would be very useful too. At the very least, it would make Overpass turbo more usable. Currently, Overpass turbo displays everything from every year on the map, and its interactive map export option is broken.
At WikiConference North America + Mapping USA, multiple Wikimedians expressed a desire to embed an interactive map from OpenHistoricalMap into a Wikipedia article about a historical topic, just as the Kartographer extension currently embeds OpenStreetMap-based maps into geography articles. At some point, we should open a similar issue in Phabricator to make sure this is on the MediaWiki/Wikimedia team’s radar, in case there’s anything they’d need to build out on their end.
Short-term, we could do this with an iframe-able GH Pages application (though does that deploy though ohm-deploy) with params, and then a button on the UI that gives you that iframe link, like embed.openhistoricalmap.org
OHM website already provides a simple tool for this. Right side of the screen, Share, then select HTML. This includes an iframe code bit.
However, there's one last step.
The OHM website code sets X-Frame-Options: sameorigin, explicitly disallowing use of maps in iframe. This is defined in config/initializers/new_framework_defaults_7_0.rb and may be intended to prevent some click-jacking behaviors where someone embeds at a fake site e.g. open-historical-map.org If DevSeed would review and agree that removing this header would not be problematic, then these iframe embeds could work.
The upper map is the dedicated embed via, for which iFrames are allowed, but which doesn't include our timeslider or anything at all of our code, such as a GL map in any state. Hence the blank.gray map.
The bottom square, with the iFrame block error, is an attempt to iframe in the home page itself. That indeed fails.
@danrademacher in #485 (comment) your HTML code shows a working embed at OHM. But this is at openhistoricalmap.org (older code) and not at staging.openhistoricalmap.org (newer code).
It appears that in later OSM/OHM, there are a lot more HTTP headers added, specifically to prevent iframe usage. As such, I think that my initial assessment was correct that HTTP headers need adjustment.
Notwithstanding the frame-blocking HTTP headers, I have progress on modifying embed.html to have the vector layer and timeslider. It also loads URL params. See new gin-embedpage-202212 branch.
It also provides the URL of the embedded state (bbox, date, daterange) in two ways:
if &showembed=1 is given then this control is visible, so one may see the URL and copy it
a cross-frame postMessage is sent, which the iframe caller may choose to respond to e.g. updating some other readout or hyperlink; this is not tested, since iframe is blocked even on localhost
do something about the anti-frame header on every page
So this is 99% done, but the last lingering thing is that the date sections of the embed and View Larger map urls do not update if I interact only with the timeslider. They update when I interact with the map. Changing the timeslider should also fire off an update regardless of map interaction
Activity
1ec5 commentedon Nov 12, 2022
#433 tracks the static version of this request, which doesn’t seem like a big effort at a glance, but an embedded interactive map would be very useful too. At the very least, it would make Overpass turbo more usable. Currently, Overpass turbo displays everything from every year on the map, and its interactive map export option is broken.
1ec5 commentedon Nov 12, 2022
At WikiConference North America + Mapping USA, multiple Wikimedians expressed a desire to embed an interactive map from OpenHistoricalMap into a Wikipedia article about a historical topic, just as the Kartographer extension currently embeds OpenStreetMap-based maps into geography articles. At some point, we should open a similar issue in Phabricator to make sure this is on the MediaWiki/Wikimedia team’s radar, in case there’s anything they’d need to build out on their end.
danrademacher commentedon Nov 15, 2022
Short-term, we could do this with an iframe-able GH Pages application (though does that deploy though
ohm-deploy) with params, and then a button on the UI that gives you that iframe link, like embed.openhistoricalmap.orgLonger-term, we might redo this as https://developer.mozilla.org/en-US/docs/Web/Web_Components
danrademacher commentedon Nov 15, 2022
We already have this https://openhistoricalmap.github.io/leaflet-ohm-timeslider-v2/ as a standalone demo that might server as the basis for an iframe-based embed -- need to check with @gregallensworth to remind me if the url params for timeline settings and mapbounds work there or if they currently need to be mediated through the Rails application
gregallensworth commentedon Nov 29, 2022
When the OHM map us used, the URL params are automagically updated to match the state. Loading these same params will set the timeslider and map location, e.g. https://www.openhistoricalmap.org/#map=17/47.60212/-122.33169&layers=O&date=1885-01-14&daterange=1860-01-01,1900-12-31 So in theory, this could be used in a simple iframe.
OHM website already provides a simple tool for this. Right side of the screen, Share, then select HTML. This includes an iframe code bit.
However, there's one last step.
The OHM website code sets
X-Frame-Options: sameorigin, explicitly disallowing use of maps in iframe. This is defined inconfig/initializers/new_framework_defaults_7_0.rband may be intended to prevent some click-jacking behaviors where someone embeds at a fake site e.g. open-historical-map.org If DevSeed would review and agree that removing this header would not be problematic, then these iframe embeds could work.danrademacher commentedon Dec 28, 2022
I don't think we need to change the headers on the home page, at least base don my local test of this HTML:
That renders like this:

The upper map is the dedicated embed via, for which iFrames are allowed, but which doesn't include our timeslider or anything at all of our code, such as a GL map in any state. Hence the blank.gray map.
The bottom square, with the iFrame block error, is an attempt to iframe in the home page itself. That indeed fails.
So I think what we want to do here is to modify this otherwise super barebones file:
https://github.com/OpenHistoricalMap/ohm-website/blob/staging/app/views/export/embed.html.erb
to do the following:
gregallensworth commentedon Dec 28, 2022
Nice. I was not aware that they had a special template just for iframe usage, which has CORS enabled.
Target files:
Hopefully much of the code could be lifted from app/assets/javascripts/index/*.js
Of course, this now means that changes to the timeslider et al now need to be done and tested in a third place:
1ec5 commentedon Dec 28, 2022
As far as I know, iD doesn’t use the time slider at all. It has its own date filter implementation.
gregallensworth commentedon Dec 28, 2022
@danrademacher in #485 (comment) your HTML code shows a working embed at OHM. But this is at openhistoricalmap.org (older code) and not at staging.openhistoricalmap.org (newer code).
When I try to use the embed.html at Staging in a iframe, it fails due to CORS.
This is also true at local-dev http://localhost:3000/ where these same headers are present.
It appears that in later OSM/OHM, there are a lot more HTTP headers added, specifically to prevent iframe usage. As such, I think that my initial assessment was correct that HTTP headers need adjustment.
Interestingly, I do see that at OSM.org these two pages have very different sets of headers. Maybe this page has some configuration to leave out headers, or maybe it's a configuration thing in their website/proxy setup (presumably AWS or similar?). But so long as current OSM is always blocking frames on all pages, working in embed.html will not produce desired results.
https://www.openstreetmap.org/export/embed.html#map=18/34.89792/-117.02087
https://www.openstreetmap.org/export/?map=18/34.89792/-117.02087
Screenshot: Staging will not iframe
Iframe src = https://staging.openhistoricalmap.org/export/embed.html?bbox=-122.34541296958925%2C47.597655606174925%2C-122.32064008712769%2C47.60656812544093&layer=historical
Screenshot: Headers on openhistoricalmap.org
https://openhistoricalmap.org/export/embed.html?bbox=-122.34541296958925%2C47.597655606174925%2C-122.32064008712769%2C47.60656812544093&layer=historical
Screenshot: Headers on staging.openhistoricalmap.org
There are a lot more here, including frame blocking, even on the embed page.
https://staging.openhistoricalmap.org/export/embed.html?bbox=-122.34541296958925%2C47.597655606174925%2C-122.32064008712769%2C47.60656812544093&layer=historical
gregallensworth commentedon Dec 28, 2022
Notwithstanding the frame-blocking HTTP headers, I have progress on modifying embed.html to have the vector layer and timeslider. It also loads URL params. See new
gin-embedpage-202212branch.http://localhost:3000/export/embed.html?bbox=-122.345413,47.59765,-122.32064,47.60656&date=1900-07-01&daterange=1860-06-01,2000-06-30&showembed=1
It also provides the URL of the embedded state (bbox, date, daterange) in two ways:
&showembed=1is given then this control is visible, so one may see the URL and copy itexport/embed.html per OpenHistoricalMap/issues#485
jeffreyameyer commentedon Apr 26, 2023
How's this coming along?
Should we reposition / retitle this ticket as something like: "Provide support for iframe-embeddable OHM maps"?
Reason I'm asking: I'm wondering if I should file a ticket for: "Provide xyz tile endpoints for period-specific OHM-created raster tiles"...
13 remaining items
erictheise commentedon Sep 12, 2023
Oops, forgot that issues was a repository separate from the code.
This commit makes the requested changes to the
iframe srcurl as I understand them.danrademacher commentedon Oct 16, 2023
For the record, this is the repo for the embed itself, https://github.com/OpenHistoricalMap/ohm-embed-1yr
More on OpenHistoricalMap/issues#485; requires changes on OpenHistori…
erictheise commentedon Oct 17, 2023
Working with this area
we can see the difference between the
/#map=approach and the/?bbox=approach.Part of OpenHistoricalMap/issues#485, embedded maps. Updates URLs and…
Finished OpenHistoricalMap/issues#485 by leveraging updated MapLibre …
Finishes OpenHistoricalMap/issues#485 by leveraging updated MapLibre …
Finishes OpenHistoricalMap/issues#485 by leveraging updated MapLibre …
danrademacher commentedon Jan 24, 2024
So this is 99% done, but the last lingering thing is that the date sections of the embed and View Larger map urls do not update if I interact only with the timeslider. They update when I interact with the map. Changing the timeslider should also fire off an update regardless of map interaction