facilmap/frontend
Candid Dauth 945487f27a Allow empty symbol/shape when fixed 2021-04-04 14:08:40 +02:00
..
src Allow empty symbol/shape when fixed 2021-04-04 14:08:40 +02:00
static Restructuring, move some files to static/, outsource common frontend functions 2017-03-01 19:52:50 +01:00
.npmignore Split into 3 reusable modules and document them (#34), bump version to 2.3.0 2017-02-22 03:45:35 +01:00
README.md Update READMEs 2021-04-02 11:19:52 +02:00
iframe-test.html Bugfixing 2021-04-02 00:49:32 +02:00
jest.config.js Status commit 2021-03-04 16:45:34 +01:00
package.json v3.0.0-beta3 2021-04-02 11:30:05 +02:00
tsconfig.json Status commit 2021-03-25 20:34:48 +01:00
webpack.config.ts Enable cache for JS bundles again 2021-04-02 10:01:03 +02:00

README.md

Embedding FacilMap into a website

Using an iframe

It is perfectly fine to embed a map from facilmap.org into an iframe.

<iframe style="height: 500px; width: 100%; border: none;" src="https://facilmap.org/mymap"></iframe>

If you use a map ID that does not exist yet, the “Create Collaborative Map” dialog will be opened when accessing the map.

You can control the display of different components by using the following query parameters:

  • toolbox: Show the toolbox (default: true)
  • search: Show the search bar (default: true)
  • autofocus: Autofocus the search field (default: false)
  • legend: Show the legend if available (default: true)
  • interactive: Show certain items (“Create collaborative map”, “Open file”) in the toolbox (default: false)

Example:

<iframe style="height: 500px; width: 100%; border: none;" src="https://facilmap.org/mymap?search=false&amp;toolbox=false"></iframe>

To synchronize the map state with the location hash (to add something like #9/31/24 to the address bar of the browser to indicate the current map view), add the following script:

<iframe id="facilmap" style="height: 500px; width: 100%; border: none;" src="https://facilmap.org/mymap"></iframe>
<script>
	window.addEventListener("message", function(evt) {
		if(evt.data && evt.data.type == "facilmap-hash" && location.hash != "#" + evt.data.hash)
			location.replace("#" + evt.data.hash);
	});

	function handleHashChange() {
		var iframe = document.getElementById("facilmap");
		iframe.src = iframe.src.replace(/(#.*)?$/, "") + location.hash;
	}

	window.addEventListener("hashchange", handleHashChange);
	if (location.hash)
		handleHashChange();
</script>