mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 16:01:15 +01:00
Remove logging and force OL3 to redraw
This commit is contained in:
parent
5d68867840
commit
42fd5dcfa7
7 changed files with 21 additions and 25 deletions
|
@ -25,7 +25,7 @@ export default class App extends React.Component {
|
||||||
console.log('Falling back to local storage for storing styles')
|
console.log('Falling back to local storage for storing styles')
|
||||||
this.styleStore = new StyleStore()
|
this.styleStore = new StyleStore()
|
||||||
}
|
}
|
||||||
this.styleStore.latestStyle(mapStyle => this.onStyleOpen(mapStyle))
|
this.styleStore.latestStyle(mapStyle => this.onStyleChanged(mapStyle))
|
||||||
})
|
})
|
||||||
|
|
||||||
this.settingsStore = new SettingsStore()
|
this.settingsStore = new SettingsStore()
|
||||||
|
@ -45,23 +45,15 @@ export default class App extends React.Component {
|
||||||
const mapStyle = this.state.mapStyle
|
const mapStyle = this.state.mapStyle
|
||||||
const blob = new Blob([JSON.stringify(mapStyle, null, 4)], {type: "application/json;charset=utf-8"});
|
const blob = new Blob([JSON.stringify(mapStyle, null, 4)], {type: "application/json;charset=utf-8"});
|
||||||
saveAs(blob, mapStyle.id + ".json");
|
saveAs(blob, mapStyle.id + ".json");
|
||||||
this.onStyleSave()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onStyleOpen(newStyle) {
|
saveStyle(snapshotStyle) {
|
||||||
console.log('upload', newStyle)
|
snapshotStyle.modified = new Date().toJSON()
|
||||||
const savedStyle = this.styleStore.save(newStyle)
|
|
||||||
this.setState({ mapStyle: savedStyle })
|
|
||||||
}
|
|
||||||
|
|
||||||
onStyleSave() {
|
|
||||||
const snapshotStyle = this.state.mapStyle.modified = new Date().toJSON()
|
|
||||||
this.setState({ mapStyle: snapshotStyle })
|
|
||||||
console.log('Save')
|
|
||||||
this.styleStore.save(snapshotStyle)
|
this.styleStore.save(snapshotStyle)
|
||||||
}
|
}
|
||||||
|
|
||||||
onStyleChanged(newStyle) {
|
onStyleChanged(newStyle) {
|
||||||
|
this.saveStyle(newStyle)
|
||||||
this.setState({ mapStyle: newStyle })
|
this.setState({ mapStyle: newStyle })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +67,7 @@ export default class App extends React.Component {
|
||||||
...this.state.mapStyle,
|
...this.state.mapStyle,
|
||||||
layers: changedLayers
|
layers: changedLayers
|
||||||
}
|
}
|
||||||
this.setState({ mapStyle: changedStyle })
|
this.onStyleChanged(changedStyle)
|
||||||
}
|
}
|
||||||
|
|
||||||
onLayerIdChange(oldId, newId) {
|
onLayerIdChange(oldId, newId) {
|
||||||
|
@ -91,7 +83,6 @@ export default class App extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onLayerChanged(layer) {
|
onLayerChanged(layer) {
|
||||||
console.log('layer changed', layer)
|
|
||||||
const changedLayers = this.state.mapStyle.layers.slice(0)
|
const changedLayers = this.state.mapStyle.layers.slice(0)
|
||||||
const idx = style.indexOfLayer(changedLayers, layer.id)
|
const idx = style.indexOfLayer(changedLayers, layer.id)
|
||||||
changedLayers[idx] = layer
|
changedLayers[idx] = layer
|
||||||
|
@ -131,8 +122,7 @@ export default class App extends React.Component {
|
||||||
const toolbar = <Toolbar
|
const toolbar = <Toolbar
|
||||||
mapStyle={this.state.mapStyle}
|
mapStyle={this.state.mapStyle}
|
||||||
onStyleChanged={this.onStyleChanged.bind(this)}
|
onStyleChanged={this.onStyleChanged.bind(this)}
|
||||||
onStyleSave={this.onStyleSave.bind(this)}
|
onStyleOpen={this.onStyleChanged.bind(this)}
|
||||||
onStyleOpen={this.onStyleOpen.bind(this)}
|
|
||||||
onStyleDownload={this.onStyleDownload.bind(this)}
|
onStyleDownload={this.onStyleDownload.bind(this)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -79,8 +79,6 @@ export default class Toolbar extends React.Component {
|
||||||
onStyleOpen: React.PropTypes.func.isRequired,
|
onStyleOpen: React.PropTypes.func.isRequired,
|
||||||
// Current style is requested for download
|
// Current style is requested for download
|
||||||
onStyleDownload: React.PropTypes.func.isRequired,
|
onStyleDownload: React.PropTypes.func.isRequired,
|
||||||
// Style is explicitely saved to local cache
|
|
||||||
onStyleSave: React.PropTypes.func,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ class ColorField extends React.Component {
|
||||||
left: pos.left + 165,
|
left: pos.left + 165,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('No elem!!')
|
console.warn('Color field has no element to adjust position')
|
||||||
return {
|
return {
|
||||||
top: 160,
|
top: 160,
|
||||||
left: 500,
|
left: 500,
|
||||||
|
|
|
@ -35,7 +35,6 @@ export default class PropertyGroup extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(this.props.layer.id, this.props.groupFields)
|
|
||||||
const fields = this.props.groupFields.map(fieldName => {
|
const fields = this.props.groupFields.map(fieldName => {
|
||||||
const fieldSpec = getFieldSpec(this.props.layer.type, fieldName)
|
const fieldSpec = getFieldSpec(this.props.layer.type, fieldName)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,14 @@ class OpenLayers3Map extends Map {
|
||||||
const olms = require('ol-mapbox-style')
|
const olms = require('ol-mapbox-style')
|
||||||
const jsonStyle = nextProps.mapStyle
|
const jsonStyle = nextProps.mapStyle
|
||||||
const styleFunc = olms.getStyleFunction(jsonStyle, 'openmaptiles', this.resolutions)
|
const styleFunc = olms.getStyleFunction(jsonStyle, 'openmaptiles', this.resolutions)
|
||||||
this.layer.setStyle(styleFunc)
|
console.log('New style babee')
|
||||||
|
|
||||||
|
const layer = this.layer
|
||||||
|
layer.setStyle(styleFunc)
|
||||||
|
//NOTE: We need to mark the source as changed in order
|
||||||
|
//to trigger a rerender
|
||||||
|
layer.getSource().changed()
|
||||||
|
|
||||||
this.state.map.render()
|
this.state.map.render()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -43,7 +50,6 @@ class OpenLayers3Map extends Map {
|
||||||
const styleFunc = olms.getStyleFunction(jsonStyle, 'openmaptiles', this.resolutions)
|
const styleFunc = olms.getStyleFunction(jsonStyle, 'openmaptiles', this.resolutions)
|
||||||
this.layer.setStyle(styleFunc)
|
this.layer.setStyle(styleFunc)
|
||||||
|
|
||||||
console.log(jsonStyle.center, jsonStyle.zoom)
|
|
||||||
const map = new ol.Map({
|
const map = new ol.Map({
|
||||||
target: this.container,
|
target: this.container,
|
||||||
layers: [this.layer],
|
layers: [this.layer],
|
||||||
|
|
|
@ -195,7 +195,11 @@ class SourcesModal extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const activeSources = Object.keys(this.props.mapStyle.sources).map(sourceId => {
|
const activeSources = Object.keys(this.props.mapStyle.sources).map(sourceId => {
|
||||||
const source = this.props.mapStyle.sources[sourceId]
|
const source = this.props.mapStyle.sources[sourceId]
|
||||||
return <SourceEditorLayout sourceId={sourceId} source={source} />
|
return <SourceEditorLayout
|
||||||
|
key={sourceId}
|
||||||
|
sourceId={sourceId}
|
||||||
|
source={source}
|
||||||
|
/>
|
||||||
})
|
})
|
||||||
|
|
||||||
const tilesetOptions = publicSources.filter(source => !(source.id in this.props.mapStyle.sources)).map(source => {
|
const tilesetOptions = publicSources.filter(source => !(source.id in this.props.mapStyle.sources)).map(source => {
|
||||||
|
|
|
@ -45,7 +45,6 @@ export default class LayerWatcher {
|
||||||
this._vectorLayers[vectorLayerId] = knownProperties
|
this._vectorLayers[vectorLayerId] = knownProperties
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
console.log(this.vectorLayers)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Access all known sources and their vector tile ids */
|
/** Access all known sources and their vector tile ids */
|
||||||
|
|
Loading…
Reference in a new issue