mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 17:51:16 +01:00
Merge remote-tracking branch 'upstream/master' into feature/os-open-zoomstack
Conflicts: src/config/styles.json
This commit is contained in:
commit
6b94e9b78b
17 changed files with 136 additions and 146 deletions
22
.travis.yml
22
.travis.yml
|
@ -1,22 +0,0 @@
|
||||||
language: node_js
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: osx
|
|
||||||
node_js: "6"
|
|
||||||
- os: osx
|
|
||||||
node_js: "8"
|
|
||||||
- os: osx
|
|
||||||
node_js: "9"
|
|
||||||
install:
|
|
||||||
- npm install
|
|
||||||
script:
|
|
||||||
- mkdir public
|
|
||||||
- node --stack_size=100000 $(which npm) run build
|
|
||||||
- npm run lint
|
|
||||||
- npm run lint-styles
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
image: Visual Studio 2017
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- nodejs_version: "6"
|
|
||||||
- nodejs_version: "8"
|
- nodejs_version: "8"
|
||||||
- nodejs_version: "9"
|
- nodejs_version: "9"
|
||||||
|
- nodejs_version: "10"
|
||||||
platform:
|
platform:
|
||||||
- x86
|
- x86
|
||||||
- x64
|
- x64
|
||||||
|
|
|
@ -13,6 +13,30 @@ import docUid from '../../libs/document-uid'
|
||||||
import sortNumerically from '../../libs/sort-numerically'
|
import sortNumerically from '../../libs/sort-numerically'
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We cache a reference for each stop by its index.
|
||||||
|
*
|
||||||
|
* When the stops are reordered the references are also updated (see this.orderStops) this allows React to use the same key for the element and keep keyboard focus.
|
||||||
|
*/
|
||||||
|
function setStopRefs(props, state) {
|
||||||
|
// This is initialsed below only if required to improved performance.
|
||||||
|
let newRefs;
|
||||||
|
|
||||||
|
if(props.value && props.value.stops) {
|
||||||
|
props.value.stops.forEach((val, idx) => {
|
||||||
|
if(!state.refs.hasOwnProperty(idx)) {
|
||||||
|
if(!newRefs) {
|
||||||
|
newRefs = {...state};
|
||||||
|
}
|
||||||
|
newRefs[idx] = docUid("stop-");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return newRefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default class ZoomProperty extends React.Component {
|
export default class ZoomProperty extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
|
@ -34,36 +58,8 @@ export default class ZoomProperty extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.setState({
|
const newRefs = setStopRefs(this.props, this.state);
|
||||||
refs: this.setStopRefs(this.props)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We cache a reference for each stop by its index.
|
|
||||||
*
|
|
||||||
* When the stops are reordered the references are also updated (see this.orderStops) this allows React to use the same key for the element and keep keyboard focus.
|
|
||||||
*/
|
|
||||||
setStopRefs(props) {
|
|
||||||
// This is initialsed below only if required to improved performance.
|
|
||||||
let newRefs;
|
|
||||||
|
|
||||||
if(props.value && props.value.stops) {
|
|
||||||
props.value.stops.forEach((val, idx) => {
|
|
||||||
if(!this.state.refs.hasOwnProperty(idx)) {
|
|
||||||
if(!newRefs) {
|
|
||||||
newRefs = {...this.state.refs};
|
|
||||||
}
|
|
||||||
newRefs[idx] = docUid("stop-");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return newRefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
||||||
const newRefs = this.setStopRefs(nextProps);
|
|
||||||
if(newRefs) {
|
if(newRefs) {
|
||||||
this.setState({
|
this.setState({
|
||||||
refs: newRefs
|
refs: newRefs
|
||||||
|
@ -71,6 +67,16 @@ export default class ZoomProperty extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getDerivedStateFromProps(props, state) {
|
||||||
|
const newRefs = setStopRefs(props, state);
|
||||||
|
if(newRefs) {
|
||||||
|
return {
|
||||||
|
refs: newRefs
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Order the stops altering the refs to reflect their new position.
|
// Order the stops altering the refs to reflect their new position.
|
||||||
orderStopsByZoom(stops) {
|
orderStopsByZoom(stops) {
|
||||||
const mappedWithRef = stops
|
const mappedWithRef = stops
|
||||||
|
|
|
@ -17,8 +17,10 @@ class NumberInput extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
static getDerivedStateFromProps(props, state) {
|
||||||
this.setState({ value: nextProps.value })
|
return {
|
||||||
|
value: props.value
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
changeValue(newValue) {
|
changeValue(newValue) {
|
||||||
|
|
|
@ -18,8 +18,10 @@ class StringInput extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
static getDerivedStateFromProps(props, state) {
|
||||||
this.setState({ value: nextProps.value || '' })
|
return {
|
||||||
|
value: props.value || ''
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -10,6 +10,10 @@ export default class CollapseAlt extends React.Component {
|
||||||
children: PropTypes.element.isRequired
|
children: PropTypes.element.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
isActive: true
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (accessibility.reducedMotionEnabled()) {
|
if (accessibility.reducedMotionEnabled()) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -29,10 +29,10 @@ class JSONEditor extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
static getDerivedStateFromProps(props, state) {
|
||||||
this.setState({
|
return {
|
||||||
code: JSON.stringify(nextProps.layer, null, 2)
|
code: JSON.stringify(props.layer, null, 2)
|
||||||
})
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
|
|
@ -76,18 +76,18 @@ export default class LayerEditor extends React.Component {
|
||||||
this.state = { editorGroups }
|
this.state = { editorGroups }
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
static getDerivedStateFromProps(props, state) {
|
||||||
const additionalGroups = { ...this.state.editorGroups }
|
const additionalGroups = { ...state.editorGroups }
|
||||||
|
|
||||||
layout[nextProps.layer.type].groups.forEach(group => {
|
layout[props.layer.type].groups.forEach(group => {
|
||||||
if(!(group.title in additionalGroups)) {
|
if(!(group.title in additionalGroups)) {
|
||||||
additionalGroups[group.title] = true
|
additionalGroups[group.title] = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this.setState({
|
return {
|
||||||
editorGroups: additionalGroups
|
editorGroups: additionalGroups
|
||||||
})
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildContext () {
|
getChildContext () {
|
||||||
|
|
|
@ -114,7 +114,7 @@ class LayerListItem extends React.Component {
|
||||||
/>
|
/>
|
||||||
<IconAction
|
<IconAction
|
||||||
wdKey={"layer-list-item:"+this.props.layerId+":toggle-visibility"}
|
wdKey={"layer-list-item:"+this.props.layerId+":toggle-visibility"}
|
||||||
action={this.props.visibility === 'visible' ? 'hide' : 'show'}
|
action={this.props.visibility === 'visible' ? 'show' : 'hide'}
|
||||||
onClick={e => this.props.onLayerVisibilityToggle(this.props.layerId)}
|
onClick={e => this.props.onLayerVisibilityToggle(this.props.layerId)}
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -83,17 +83,17 @@ export default class MapboxGlMap extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
updateMapFromProps(props) {
|
||||||
if(!IS_SUPPORTED) return;
|
if(!IS_SUPPORTED) return;
|
||||||
|
|
||||||
if(!this.state.map) return
|
if(!this.state.map) return
|
||||||
const metadata = nextProps.mapStyle.metadata || {}
|
const metadata = props.mapStyle.metadata || {}
|
||||||
MapboxGl.accessToken = metadata['maputnik:mapbox_access_token'] || tokens.mapbox
|
MapboxGl.accessToken = metadata['maputnik:mapbox_access_token'] || tokens.mapbox
|
||||||
|
|
||||||
if(!nextProps.inspectModeEnabled) {
|
if(!props.inspectModeEnabled) {
|
||||||
//Mapbox GL now does diffing natively so we don't need to calculate
|
//Mapbox GL now does diffing natively so we don't need to calculate
|
||||||
//the necessary operations ourselves!
|
//the necessary operations ourselves!
|
||||||
this.state.map.setStyle(nextProps.mapStyle, { diff: true})
|
this.state.map.setStyle(props.mapStyle, { diff: true})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +102,8 @@ export default class MapboxGlMap extends React.Component {
|
||||||
|
|
||||||
const map = this.state.map;
|
const map = this.state.map;
|
||||||
|
|
||||||
|
this.updateMapFromProps(this.props);
|
||||||
|
|
||||||
if(this.props.inspectModeEnabled !== prevProps.inspectModeEnabled) {
|
if(this.props.inspectModeEnabled !== prevProps.inspectModeEnabled) {
|
||||||
this.state.inspect.toggleInspector()
|
this.state.inspect.toggleInspector()
|
||||||
}
|
}
|
||||||
|
@ -109,9 +111,11 @@ export default class MapboxGlMap extends React.Component {
|
||||||
this.state.inspect.render()
|
this.state.inspect.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (map) {
|
||||||
map.showTileBoundaries = this.props.options.showTileBoundaries;
|
map.showTileBoundaries = this.props.options.showTileBoundaries;
|
||||||
map.showCollisionBoxes = this.props.options.showCollisionBoxes;
|
map.showCollisionBoxes = this.props.options.showCollisionBoxes;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if(!IS_SUPPORTED) return;
|
if(!IS_SUPPORTED) return;
|
||||||
|
|
|
@ -27,10 +27,10 @@ class OpenLayers3Map extends React.Component {
|
||||||
const styleFunc = olms.apply(this.map, newMapStyle)
|
const styleFunc = olms.apply(this.map, newMapStyle)
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
componentDidUpdate() {
|
||||||
require.ensure(["ol", "ol-mapbox-style"], () => {
|
require.ensure(["ol", "ol-mapbox-style"], () => {
|
||||||
if(!this.map) return
|
if(!this.map) return
|
||||||
this.updateStyle(nextProps.mapStyle)
|
this.updateStyle(this.props.mapStyle)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ class OpenModal extends React.Component {
|
||||||
onStyleSelect = (styleUrl) => {
|
onStyleSelect = (styleUrl) => {
|
||||||
this.clearError();
|
this.clearError();
|
||||||
|
|
||||||
|
let canceled;
|
||||||
|
|
||||||
const activeRequest = fetch(styleUrl, {
|
const activeRequest = fetch(styleUrl, {
|
||||||
mode: 'cors',
|
mode: 'cors',
|
||||||
credentials: "same-origin"
|
credentials: "same-origin"
|
||||||
|
@ -84,6 +86,10 @@ class OpenModal extends React.Component {
|
||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
.then((body) => {
|
.then((body) => {
|
||||||
|
if(canceled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
activeRequest: null,
|
activeRequest: null,
|
||||||
activeRequestUrl: null
|
activeRequestUrl: null
|
||||||
|
@ -104,7 +110,11 @@ class OpenModal extends React.Component {
|
||||||
})
|
})
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
activeRequest: activeRequest,
|
activeRequest: {
|
||||||
|
abort: function() {
|
||||||
|
canceled = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
activeRequestUrl: styleUrl
|
activeRequestUrl: styleUrl
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -165,7 +175,9 @@ class OpenModal extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Modal
|
return (
|
||||||
|
<div>
|
||||||
|
<Modal
|
||||||
data-wd-key="open-modal"
|
data-wd-key="open-modal"
|
||||||
isOpen={this.props.isOpen}
|
isOpen={this.props.isOpen}
|
||||||
onOpenToggle={() => this.onOpenToggle()}
|
onOpenToggle={() => this.onOpenToggle()}
|
||||||
|
@ -200,6 +212,7 @@ class OpenModal extends React.Component {
|
||||||
{styleOptions}
|
{styleOptions}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
<LoadingModal
|
<LoadingModal
|
||||||
isOpen={!!this.state.activeRequest}
|
isOpen={!!this.state.activeRequest}
|
||||||
|
@ -207,7 +220,8 @@ class OpenModal extends React.Component {
|
||||||
onCancel={(e) => this.onCancelActiveRequest(e)}
|
onCancel={(e) => this.onCancelActiveRequest(e)}
|
||||||
message={"Loading: "+this.state.activeRequestUrl}
|
message={"Loading: "+this.state.activeRequestUrl}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,25 +34,6 @@
|
||||||
"title": "Empty Style",
|
"title": "Empty Style",
|
||||||
"url": "https://rawgit.com/maputnik/editor/master/src/config/empty-style.json",
|
"url": "https://rawgit.com/maputnik/editor/master/src/config/empty-style.json",
|
||||||
"thumbnail": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAECAQAAAAHDYbIAAAAEUlEQVR42mP8/58BDhiJ4wAA974H/U5Xe1oAAAAASUVORK5CYII="
|
"thumbnail": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAECAQAAAAHDYbIAAAAEUlEQVR42mP8/58BDhiJ4wAA974H/U5Xe1oAAAAASUVORK5CYII="
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "mapbox-satellite",
|
|
||||||
"title": "Mapbox Satellite",
|
|
||||||
"url": "https://rawgit.com/mapbox/mapbox-gl-styles/master/styles/satellite-v9.json",
|
|
||||||
"thumbnail": "https://maputnik.github.io/thumbnails/mapbox-satellite.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "mapbox-bright",
|
|
||||||
"title": "Mapbox Bright",
|
|
||||||
"url": "https://rawgit.com/mapbox/mapbox-gl-styles/master/styles/bright-v9.json",
|
|
||||||
"thumbnail": "https://maputnik.github.io/thumbnails/mapbox-bright.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "mapbox-basic",
|
|
||||||
"title": "Mapbox Basic",
|
|
||||||
"url": "https://rawgit.com/mapbox/mapbox-gl-styles/master/styles/basic-v9.json",
|
|
||||||
"thumbnail": "https://maputnik.github.io/thumbnails/mapbox-basic.png"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "os-zoomstack-outdoor",
|
"id": "os-zoomstack-outdoor",
|
||||||
"title": "Zoomstack Outdoor",
|
"title": "Zoomstack Outdoor",
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
{
|
{
|
||||||
"mapbox-streets": {
|
|
||||||
"type": "vector",
|
|
||||||
"url": "mapbox://mapbox.mapbox-streets-v7",
|
|
||||||
"title": "Mapbox Streets"
|
|
||||||
},
|
|
||||||
"openmaptiles": {
|
"openmaptiles": {
|
||||||
"type": "vector",
|
"type": "vector",
|
||||||
"url": "https://free.tilehosting.com/data/v3.json?key={key}",
|
"url": "https://free.tilehosting.com/data/v3.json?key={key}",
|
||||||
|
|
|
@ -102,9 +102,12 @@ function replaceAccessTokens(mapStyle, opts={}) {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (mapStyle.glyphs && mapStyle.glyphs.match(/\.tilehosting\.com/)) {
|
if (mapStyle.glyphs && mapStyle.glyphs.match(/\.tilehosting\.com/)) {
|
||||||
|
const newAccessToken = getAccessToken("openmaptiles", mapStyle, opts);
|
||||||
|
if (newAccessToken) {
|
||||||
changedStyle = {
|
changedStyle = {
|
||||||
...changedStyle,
|
...changedStyle,
|
||||||
glyphs: mapStyle.glyphs.replace('{key}', getAccessToken("openmaptiles", mapStyle, opts))
|
glyphs: mapStyle.glyphs.replace('{key}', newAccessToken)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ describe("modals", function() {
|
||||||
assert.equal(styleObj.metadata["maputnik:openmaptiles_access_token"], apiKey);
|
assert.equal(styleObj.metadata["maputnik:openmaptiles_access_token"], apiKey);
|
||||||
})
|
})
|
||||||
|
|
||||||
it("style renderer", function() {
|
it.skip("style renderer", function() {
|
||||||
var selector = wd.$("modal-settings.maputnik:renderer");
|
var selector = wd.$("modal-settings.maputnik:renderer");
|
||||||
browser.selectByValue(selector, "ol3");
|
browser.selectByValue(selector, "ol3");
|
||||||
browser.click(wd.$("modal-settings.name"))
|
browser.click(wd.$("modal-settings.name"))
|
||||||
|
|
|
@ -46,10 +46,10 @@ try {
|
||||||
browser.addCommand('flushReactUpdates', function() {
|
browser.addCommand('flushReactUpdates', function() {
|
||||||
browser.executeAsync(function(done) {
|
browser.executeAsync(function(done) {
|
||||||
// For any events to propogate
|
// For any events to propogate
|
||||||
setImmediate(function() {
|
setTimeout(function() {
|
||||||
// For the DOM to be updated.
|
// For the DOM to be updated.
|
||||||
setImmediate(done);
|
setTimeout(done, 0);
|
||||||
})
|
}, 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue