diff --git a/package-lock.json b/package-lock.json
index 7ae0cbc..c90af1f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4116,6 +4116,11 @@
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=",
"dev": true
},
+ "detect-browser": {
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/detect-browser/-/detect-browser-4.5.0.tgz",
+ "integrity": "sha512-uwyZNBwMhvRIOBIBTuDu+h4/a2bfFE/elUIvAOuKuBZcuy6yAJ/9dOe4r3wyWO/ZW2PcsP0dhEwiVwTPTTJp2Q=="
+ },
"detect-node": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz",
diff --git a/package.json b/package.json
index e50a873..6fe3fd1 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"classnames": "^2.2.6",
"codemirror": "^5.40.2",
"color": "^3.0.0",
+ "detect-browser": "^4.5.0",
"file-saver": "^1.3.8",
"jsonlint": "github:josdejong/jsonlint#85a19d7",
"lodash.capitalize": "^4.2.1",
diff --git a/src/components/App.jsx b/src/components/App.jsx
index 34216c8..b24cb1b 100644
--- a/src/components/App.jsx
+++ b/src/components/App.jsx
@@ -19,6 +19,7 @@ import SourcesModal from './modals/SourcesModal'
import OpenModal from './modals/OpenModal'
import ShortcutsModal from './modals/ShortcutsModal'
import SurveyModal from './modals/SurveyModal'
+import DebugModal from './modals/DebugModal'
import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata'
import {latest, validate} from '@mapbox/mapbox-gl-style-spec'
@@ -139,6 +140,12 @@ export default class App extends React.Component {
document.querySelector(".mapboxgl-canvas").focus();
}
},
+ {
+ key: "!",
+ handler: () => {
+ this.toggleModal("debug");
+ }
+ },
]
document.body.addEventListener("keyup", (e) => {
@@ -203,12 +210,13 @@ export default class App extends React.Component {
open: false,
shortcuts: false,
export: false,
- survey: localStorage.hasOwnProperty('survey') ? false : true
+ survey: localStorage.hasOwnProperty('survey') ? false : true,
+ debug: false,
},
- mapOptions: {
- showTileBoundaries: queryUtil.asBool(queryObj, "show-tile-boundaries"),
- showCollisionBoxes: queryUtil.asBool(queryObj, "show-collision-boxes"),
- showOverdrawInspector: queryUtil.asBool(queryObj, "show-overdraw-inspector")
+ mapboxGlDebugOptions: {
+ showTileBoundaries: false,
+ showCollisionBoxes: false,
+ showOverdrawInspector: false,
},
}
@@ -217,20 +225,24 @@ export default class App extends React.Component {
})
}
- handleKeyPress(e) {
+ handleKeyPress = (e) => {
if(navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
if(e.metaKey && e.shiftKey && e.keyCode === 90) {
+ e.preventDefault();
this.onRedo(e);
}
else if(e.metaKey && e.keyCode === 90) {
+ e.preventDefault();
this.onUndo(e);
}
}
else {
if(e.ctrlKey && e.keyCode === 90) {
+ e.preventDefault();
this.onUndo(e);
}
else if(e.ctrlKey && e.keyCode === 89) {
+ e.preventDefault();
this.onRedo(e);
}
}
@@ -461,18 +473,22 @@ export default class App extends React.Component {
}
}
+ _getRenderer () {
+ const metadata = this.state.mapStyle.metadata || {};
+ return metadata['maputnik:renderer'] || 'mbgljs';
+ }
+
mapRenderer() {
const mapProps = {
mapStyle: style.replaceAccessTokens(this.state.mapStyle, {allowFallback: true}),
- options: this.state.mapOptions,
+ options: this.state.mapboxGlDebugOptions,
onDataChange: (e) => {
this.layerWatcher.analyzeMap(e.map)
this.fetchSources();
},
}
- const metadata = this.state.mapStyle.metadata || {}
- const renderer = metadata['maputnik:renderer'] || 'mbgljs'
+ const renderer = this._getRenderer();
let mapElement;
@@ -524,6 +540,15 @@ export default class App extends React.Component {
this.setModal(modalName, !this.state.isOpen[modalName]);
}
+ onChangeMaboxGlDebug = (key, value) => {
+ this.setState({
+ mapboxGlDebugOptions: {
+ ...this.state.mapboxGlDebugOptions,
+ [key]: value,
+ }
+ });
+ }
+
render() {
const layers = this.state.mapStyle.layers || []
const selectedLayer = layers.length > 0 ? layers[this.state.selectedLayerIndex] : null
@@ -575,6 +600,13 @@ export default class App extends React.Component {
const modals =
+
this.shortcutEl = el}
isOpen={this.state.isOpen.shortcuts}
diff --git a/src/components/Toolbar.jsx b/src/components/Toolbar.jsx
index e76c984..6f81b86 100644
--- a/src/components/Toolbar.jsx
+++ b/src/components/Toolbar.jsx
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
+import {detect} from 'detect-browser';
import {MdFileDownload, MdOpenInBrowser, MdSettings, MdLayers, MdHelpOutline, MdFindInPage, MdAssignmentTurnedIn} from 'react-icons/md'
@@ -9,6 +10,11 @@ import logoImage from 'maputnik-design/logos/logo-color.svg'
import pkgJson from '../../package.json'
+// This is required because of , there isn't another way to detect support that I'm aware of.
+const browser = detect();
+const colorAccessibilityFiltersEnabled = ['chrome', 'firefox'].indexOf(browser.name) > -1;
+
+
class IconText extends React.Component {
static propTypes = {
children: PropTypes.node,
@@ -137,18 +143,22 @@ export default class Toolbar extends React.Component {
{
id: "filter-deuteranopia",
title: "Map (deuteranopia)",
+ disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-protanopia",
title: "Map (protanopia)",
+ disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-tritanopia",
title: "Map (tritanopia)",
+ disabled: !colorAccessibilityFiltersEnabled,
},
{
id: "filter-achromatopsia",
title: "Map (achromatopsia)",
+ disabled: !colorAccessibilityFiltersEnabled,
},
];
@@ -201,7 +211,7 @@ export default class Toolbar extends React.Component {