-
Notifications
You must be signed in to change notification settings - Fork 58
Better embedding support #316
Comments
Change to meshviewer itself is minimal: In main.js, before the router is created, I just added:
This changes in the hash so that the embedding window can access it. The embed.js I created looks like this:
This works almost completely with one error. It seems that meshviewer has a race condition between initializing the app and reacting on hash changes. So the line
Edit: The race condition can be workarounded by running the initial setting of the hash decoupled via window.setTimeout:
|
What's currently also problematic are those Links in the |
@herbetom I think that's a different issue. I have closed my PR since it's not 100% working. My (working) changes are in https://git.dezentrale.cloud/Freifunk-Leipzig/meshviewer/src/branch/ffle now. The structure of meshviewer makes it hard to do proper PRs since the repo mixes config and development. When I find a little time, I try to move the config out of the project (so that it's loaded dynamically). With that, community specific changes can be maintained independently of coding changes which allows good PRs as well as building releases. |
Yeah, our solution is pretty old and meshviewer changed a lot over time (e.,g. new URL router) and APIs in browsers changed and improved. This comment captures it pretty well |
Is your feature request related to a problem? Please describe.
Currently, when embedding the map in an iframe, deep linking is problematic. The Demo at https://regensburg.freifunk.net/netz/karte/ has a partial solution which could easily improved.
Meshviewer handles deep links via URL anchors (like
#!/de/map/a42bb0c909aa
). The Demo hosts meshviewer on the same domain as the embedding page and polls the iframe for URL changes. This allows to change the main page URL when the embedded URL is changed. This will not work, if meshviewer runs on a separate domain. Also there's no handling for deep links, so an URL like https://regensburg.freifunk.net/netz/karte/node/14cc2097d7d6/ will always show the full map with no node selected.Describe the solution you'd like
Modify mapviewer to advertise url anchor changes via window.postMessage (https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage). This allows to cunsume these events on the embedding window without polling and works also on cross-domain setups.
Provide a javascript as part of meshviewer that handles and embedded meshviewer:
With this, embedding a meshviewer with working deep-linking would be as easy as
The text was updated successfully, but these errors were encountered: