Open Infrastructure Map, a view of infrastructure data in OpenStreetMap
Add WebGL warning
Russ Garrett1ce012fdf04e
diff --git a/src/index.css b/src/index.cssindex c5a922e..6b6a126 100644--- a/src/index.css+++ b/src/index.css@@ -43,3 +43,33 @@ h1 {a {color: #333;}++.infobox {+ display: block;+ position: absolute;+ bottom: 40px;+ min-width: 60px;+ max-width: 300px;+ left: 5%;+ background-color: white;+ padding: 5px;+ border: 1px solid #999;+ border-radius: 4px;+}++.infobox-header {+ font-weight: bold;+ padding-bottom: 5px;+ border-bottom: 1px solid #bbb;+ margin-bottom: 4px;+}++.infobox-header a {+ cursor: pointer;+ float: right;+ margin-top: -3px;+}++.infobox-content {+ clear: both;+}diff --git a/src/index.js b/src/index.jsindex f633f05..2ca115c 100644--- a/src/index.js+++ b/src/index.js@@ -2,7 +2,10 @@ import './index.css';import mapboxgl from 'mapbox-gl';import map_style from './style.json';+import { mount } from 'redom';+import EditButton from './editbutton.js';+import InfoBox from './infobox.js';import style_base from './style_base.js';import style_oim_power from './style_oim_power.js';@@ -49,6 +52,14 @@ function init() {});map.addControl(new mapboxgl.NavigationControl(), 'top-right');map.addControl(new EditButton(), 'bottom-right');++ if (!mapboxgl.supported({failIfMajorPerformanceCaveat: true})) {+ const infobox = new InfoBox('Warning');+ infobox.update('Your browser may have performance or functionality issues with OpenInfraMap.<br/>' ++ '<a href="http://webglreport.com">WebGL</a> with hardware acceleration is required for this site ' ++ 'to perform well.');+ mount(document.body, infobox);+ }}if (document.readyState != 'loading') {diff --git a/src/infobox.js b/src/infobox.jsnew file mode 100644index 0000000..15c7318--- /dev/null+++ b/src/infobox.js@@ -0,0 +1,22 @@+import { el, unmount } from 'redom';++class InfoBox {+ constructor (title) {+ this.content = el('div', {'class': 'infobox-content'});+ const closebutton = el('a', '×');+ const header = el('div', title, closebutton, {'class': 'infobox-header'});++ this.el = el('div', header, this.content, {'class': 'infobox'});++ closebutton.onclick = (e) => {+ unmount(document.body, this.el);+ e.preventDefault();+ }+ }++ update(data) {+ this.content.innerHTML = data;+ }+}++export default InfoBox;