mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-01 00:43:15 +01:00
Added semi-hidden debug modal and removed all this url param awkwardness
This commit is contained in:
parent
c3c0c35d8a
commit
d2ffc3a0b1
3 changed files with 67 additions and 4 deletions
|
@ -19,6 +19,7 @@ import SourcesModal from './modals/SourcesModal'
|
||||||
import OpenModal from './modals/OpenModal'
|
import OpenModal from './modals/OpenModal'
|
||||||
import ShortcutsModal from './modals/ShortcutsModal'
|
import ShortcutsModal from './modals/ShortcutsModal'
|
||||||
import SurveyModal from './modals/SurveyModal'
|
import SurveyModal from './modals/SurveyModal'
|
||||||
|
import DebugModal from './modals/DebugModal'
|
||||||
|
|
||||||
import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata'
|
import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata'
|
||||||
import {latest, validate} from '@mapbox/mapbox-gl-style-spec'
|
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();
|
document.querySelector(".mapboxgl-canvas").focus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "!",
|
||||||
|
handler: () => {
|
||||||
|
this.toggleModal("debug");
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
document.body.addEventListener("keyup", (e) => {
|
document.body.addEventListener("keyup", (e) => {
|
||||||
|
@ -203,12 +210,13 @@ export default class App extends React.Component {
|
||||||
open: false,
|
open: false,
|
||||||
shortcuts: false,
|
shortcuts: false,
|
||||||
export: false,
|
export: false,
|
||||||
survey: localStorage.hasOwnProperty('survey') ? false : true
|
survey: localStorage.hasOwnProperty('survey') ? false : true,
|
||||||
|
debug: false,
|
||||||
},
|
},
|
||||||
mapOptions: {
|
mapOptions: {
|
||||||
showTileBoundaries: queryUtil.asBool(queryObj, "show-tile-boundaries"),
|
showTileBoundaries: false,
|
||||||
showCollisionBoxes: queryUtil.asBool(queryObj, "show-collision-boxes"),
|
showCollisionBoxes: false,
|
||||||
showOverdrawInspector: queryUtil.asBool(queryObj, "show-overdraw-inspector")
|
showOverdrawInspector: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,6 +532,15 @@ export default class App extends React.Component {
|
||||||
this.setModal(modalName, !this.state.isOpen[modalName]);
|
this.setModal(modalName, !this.state.isOpen[modalName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChangeDebug = (key, value) => {
|
||||||
|
this.setState({
|
||||||
|
mapOptions: {
|
||||||
|
...this.state.mapOptions,
|
||||||
|
[key]: value,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const layers = this.state.mapStyle.layers || []
|
const layers = this.state.mapStyle.layers || []
|
||||||
const selectedLayer = layers.length > 0 ? layers[this.state.selectedLayerIndex] : null
|
const selectedLayer = layers.length > 0 ? layers[this.state.selectedLayerIndex] : null
|
||||||
|
@ -575,6 +592,12 @@ export default class App extends React.Component {
|
||||||
|
|
||||||
|
|
||||||
const modals = <div>
|
const modals = <div>
|
||||||
|
<DebugModal
|
||||||
|
debugOptions={this.state.mapOptions}
|
||||||
|
onChangeDebug={this.onChangeDebug}
|
||||||
|
isOpen={this.state.isOpen.debug}
|
||||||
|
onOpenToggle={this.toggleModal.bind(this, 'debug')}
|
||||||
|
/>
|
||||||
<ShortcutsModal
|
<ShortcutsModal
|
||||||
ref={(el) => this.shortcutEl = el}
|
ref={(el) => this.shortcutEl = el}
|
||||||
isOpen={this.state.isOpen.shortcuts}
|
isOpen={this.state.isOpen.shortcuts}
|
||||||
|
|
36
src/components/modals/DebugModal.js
Normal file
36
src/components/modals/DebugModal.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
|
import Modal from './Modal'
|
||||||
|
|
||||||
|
|
||||||
|
class DebugModal extends React.Component {
|
||||||
|
static propTypes = {
|
||||||
|
isOpen: PropTypes.bool.isRequired,
|
||||||
|
onOpenToggle: PropTypes.func.isRequired,
|
||||||
|
debugOptions: PropTypes.object,
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <Modal
|
||||||
|
data-wd-key="debug-modal"
|
||||||
|
isOpen={this.props.isOpen}
|
||||||
|
onOpenToggle={this.props.onOpenToggle}
|
||||||
|
title={'Debug'}
|
||||||
|
>
|
||||||
|
<div className="maputnik-modal-section maputnik-modal-shortcuts">
|
||||||
|
<ul>
|
||||||
|
{Object.entries(this.props.debugOptions).map(([key, val]) => {
|
||||||
|
return <li key={key}>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" value={val} onClick={(e) => this.props.onChangeDebug(key, e.target.checked)} /> {key}
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DebugModal;
|
|
@ -40,6 +40,10 @@ class ShortcutsModal extends React.Component {
|
||||||
key: "m",
|
key: "m",
|
||||||
text: "Focus map"
|
text: "Focus map"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "!",
|
||||||
|
text: "Debug modal"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue