diff --git a/README.md b/README.md
index e535aa7..27f86ac 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,10 @@ npm run lint
npm run lint-styles
```
+## Related Projects
+
+- [maputnik-dev-server](https://github.com/nycplanning/labs-maputnik-dev-server) - An express.js server that allows for quickly loading the style from any mapboxGL map into mapuntnik.
+
## Sponsors
Thanks to the supporters of the **[Kickstarter campaign](https://www.kickstarter.com/projects/174808720/maputnik-visual-map-editor-for-mapbox-gl)**. This project would not be possible without these commercial and individual sponsors.
diff --git a/config/webpack.loaders.js b/config/webpack.loaders.js
index 438c3b8..05e3416 100644
--- a/config/webpack.loaders.js
+++ b/config/webpack.loaders.js
@@ -6,7 +6,7 @@ module.exports = [
},
{
test: /\.jsx?$/,
- exclude: /(node_modules|bower_components|public)/,
+ exclude: /(.*node_modules(?![\/\\]@mapbox[\/\\]mapbox-gl-style-spec)|bower_components|public)/,
loader: 'babel',
query: {
presets: ['es2015', 'react'],
diff --git a/config/webpack.production.config.js b/config/webpack.production.config.js
index 66d582c..f4576da 100644
--- a/config/webpack.production.config.js
+++ b/config/webpack.production.config.js
@@ -20,8 +20,6 @@ module.exports = {
vendor: [
'file-saver',
'mapbox-gl/dist/mapbox-gl.js',
- //TODO: Build failure because cannot resolve migrations file
- //"mapbox-gl-style-spec",
"lodash.clonedeep",
"lodash.throttle",
'color',
diff --git a/package.json b/package.json
index 6290477..5471a5d 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"license": "MIT",
"homepage": "https://github.com/maputnik/editor#readme",
"dependencies": {
+ "@mapbox/mapbox-gl-style-spec": "^9.0.0",
"@mapbox/mapbox-gl-rtl-text": "^0.1.0",
"classnames": "^2.2.5",
"codemirror": "^5.18.2",
@@ -31,9 +32,8 @@
"lodash.clonedeep": "^4.5.0",
"lodash.isequal": "^4.4.0",
"lodash.throttle": "^4.1.1",
- "mapbox-gl": "^0.33.0",
- "mapbox-gl-inspect": "^1.2.2",
- "mapbox-gl-style-spec": "^8.11.0",
+ "mapbox-gl": "^0.34.0",
+ "mapbox-gl-inspect": "^1.2.3",
"mousetrap": "^1.6.0",
"ol-mapbox-style": "1.0.1",
"openlayers": "^3.19.1",
diff --git a/src/components/App.jsx b/src/components/App.jsx
index ba10485..4f0f68c 100644
--- a/src/components/App.jsx
+++ b/src/components/App.jsx
@@ -10,9 +10,7 @@ import AppLayout from './AppLayout'
import MessagePanel from './MessagePanel'
import { downloadGlyphsMetadata, downloadSpriteMetadata } from '../libs/metadata'
-import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
-import validateStyleMin from 'mapbox-gl-style-spec/lib/validate_style.min'
-import formatStyle from 'mapbox-gl-style-spec/lib/format'
+import styleSpec from '@mapbox/mapbox-gl-style-spec'
import style from '../libs/style.js'
import { initialStyleUrl, loadStyleUrl } from '../libs/urlopen'
import { undoMessages, redoMessages } from '../libs/diffmessage'
@@ -65,7 +63,7 @@ export default class App extends React.Component {
sources: {},
vectorLayers: {},
inspectModeEnabled: false,
- spec: GlSpec,
+ spec: styleSpec.latest,
}
this.layerWatcher = new LayerWatcher({
@@ -115,7 +113,7 @@ export default class App extends React.Component {
this.updateIcons(newStyle.sprite)
}
- const errors = validateStyleMin(newStyle, GlSpec)
+ const errors = styleSpec.validate(newStyle, styleSpec.latest)
if(errors.length === 0) {
this.revisionStore.addRevision(newStyle)
if(save) this.saveStyle(newStyle)
diff --git a/src/components/filter/FilterEditor.jsx b/src/components/filter/FilterEditor.jsx
index fcfe7d8..8641548 100644
--- a/src/components/filter/FilterEditor.jsx
+++ b/src/components/filter/FilterEditor.jsx
@@ -1,7 +1,7 @@
import React from 'react'
import { combiningFilterOps } from '../../libs/filterops.js'
-import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
+import styleSpec from '@mapbox/mapbox-gl-style-spec'
import DocLabel from '../fields/DocLabel'
import SelectInput from '../inputs/SelectInput'
import SingleFilterEditor from './SingleFilterEditor'
@@ -91,7 +91,7 @@ export default class CombiningFilterEditor extends React.Component {
+ return
+ return
+ return
+ return
+ return
}
diff --git a/src/components/layers/MinZoomBlock.jsx b/src/components/layers/MinZoomBlock.jsx
index 9585d67..c4a7f36 100644
--- a/src/components/layers/MinZoomBlock.jsx
+++ b/src/components/layers/MinZoomBlock.jsx
@@ -1,6 +1,6 @@
import React from 'react'
-import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
+import styleSpec from '@mapbox/mapbox-gl-style-spec'
import InputBlock from '../inputs/InputBlock'
import NumberInput from '../inputs/NumberInput'
@@ -11,13 +11,13 @@ class MinZoomBlock extends React.Component {
}
render() {
- return
+ return
}
diff --git a/src/components/map/MapboxGlMap.jsx b/src/components/map/MapboxGlMap.jsx
index b26bca3..11b5019 100644
--- a/src/components/map/MapboxGlMap.jsx
+++ b/src/components/map/MapboxGlMap.jsx
@@ -1,10 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
-import MapboxGl from 'mapbox-gl/dist/mapbox-gl.js'
+import MapboxGl from 'mapbox-gl'
import MapboxInspect from 'mapbox-gl-inspect'
import FeatureLayerPopup from './FeatureLayerPopup'
import FeaturePropertyPopup from './FeaturePropertyPopup'
-import validateColor from 'mapbox-gl-style-spec/lib/validate/validate_color'
import style from '../../libs/style.js'
import tokens from '../../config/tokens.json'
import colors from 'mapbox-gl-inspect/lib/colors'
diff --git a/src/components/modals/ExportModal.jsx b/src/components/modals/ExportModal.jsx
index 0a06571..b6db301 100644
--- a/src/components/modals/ExportModal.jsx
+++ b/src/components/modals/ExportModal.jsx
@@ -1,7 +1,7 @@
import React from 'react'
import { saveAs } from 'file-saver'
-import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
+import styleSpec from '@mapbox/mapbox-gl-style-spec'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import SelectInput from '../inputs/SelectInput'
@@ -10,7 +10,6 @@ import Button from '../Button'
import Modal from './Modal'
import MdFileDownload from 'react-icons/lib/md/file-download'
import style from '../../libs/style.js'
-import formatStyle from 'mapbox-gl-style-spec/lib/format'
import GitHub from 'github-api'
@@ -44,8 +43,8 @@ class Gist extends React.Component {
const preview = this.state.preview && (this.props.mapStyle.metadata || {})['maputnik:openmaptiles_access_token'];
const mapStyleStr = preview ?
- formatStyle(stripAccessTokens(style.replaceAccessToken(this.props.mapStyle))) :
- formatStyle(stripAccessTokens(this.props.mapStyle));
+ styleSpec.format(stripAccessTokens(style.replaceAccessToken(this.props.mapStyle))) :
+ styleSpec.format(stripAccessTokens(this.props.mapStyle));
const styleTitle = this.props.mapStyle.name || 'Style';
const htmlStr = `
@@ -197,7 +196,7 @@ class ExportModal extends React.Component {
}
downloadStyle() {
- const blob = new Blob([formatStyle(stripAccessTokens(this.props.mapStyle))], {type: "application/json;charset=utf-8"});
+ const blob = new Blob([styleSpec.format(stripAccessTokens(this.props.mapStyle))], {type: "application/json;charset=utf-8"});
saveAs(blob, this.props.mapStyle.id + ".json");
}
diff --git a/src/components/modals/SettingsModal.jsx b/src/components/modals/SettingsModal.jsx
index 66967c2..d3bc5b9 100644
--- a/src/components/modals/SettingsModal.jsx
+++ b/src/components/modals/SettingsModal.jsx
@@ -1,6 +1,6 @@
import React from 'react'
-import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
+import styleSpec from '@mapbox/mapbox-gl-style-spec'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import SelectInput from '../inputs/SelectInput'
@@ -46,7 +46,7 @@ class SettingsModal extends React.Component {
title={'Style Settings'}
>
-
+
-
+
-
+
this.setState({ sourceId: v})}
/>
-
+
+ return
this.props.onChange({
@@ -42,7 +42,7 @@ class TileURLSourceEditor extends React.Component {
const prefix = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th']
const tiles = this.props.source.tiles || []
return tiles.map((tileUrl, tileIndex) => {
- return
+ return
{this.renderTileUrls()}
-
+
this.props.onChange({
@@ -63,7 +63,7 @@ class TileURLSourceEditor extends React.Component {
})}
/>
-
+
this.props.onChange({
@@ -84,7 +84,7 @@ class GeoJSONSourceEditor extends React.Component {
}
render() {
- return
+ return
this.props.onChange({
diff --git a/src/libs/diffmessage.js b/src/libs/diffmessage.js
index 502c59e..a4c01cd 100644
--- a/src/libs/diffmessage.js
+++ b/src/libs/diffmessage.js
@@ -1,7 +1,7 @@
-import diffStyles from 'mapbox-gl-style-spec/lib/diff'
+import styleSpec from '@mapbox/mapbox-gl-style-spec'
export function diffMessages(beforeStyle, afterStyle) {
- const changes = diffStyles(beforeStyle, afterStyle)
+ const changes = styleSpec.diff(beforeStyle, afterStyle)
return changes.map(cmd => cmd.command + ' ' + cmd.args.join(' '))
}
diff --git a/src/libs/filterops.js b/src/libs/filterops.js
index 65984fd..892e224 100644
--- a/src/libs/filterops.js
+++ b/src/libs/filterops.js
@@ -1,6 +1,6 @@
-import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
+import styleSpec from '@mapbox/mapbox-gl-style-spec'
export const combiningFilterOps = ['all', 'any', 'none']
export const setFilterOps = ['in', '!in']
export const otherFilterOps = Object
- .keys(GlSpec.filter_operator.values)
+ .keys(styleSpec.latest.filter_operator.values)
.filter(op => combiningFilterOps.indexOf(op) < 0)
diff --git a/src/libs/layer.js b/src/libs/layer.js
index f018c46..d6ee928 100644
--- a/src/libs/layer.js
+++ b/src/libs/layer.js
@@ -1,16 +1,16 @@
-import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
+import styleSpec from '@mapbox/mapbox-gl-style-spec'
export function changeType(layer, newType) {
const changedPaintProps = { ...layer.paint }
Object.keys(changedPaintProps).forEach(propertyName => {
- if(!(propertyName in GlSpec['paint_' + newType])) {
+ if(!(propertyName in styleSpec.latest['paint_' + newType])) {
delete changedPaintProps[propertyName]
}
})
const changedLayoutProps = { ...layer.layout }
Object.keys(changedLayoutProps).forEach(propertyName => {
- if(!(propertyName in GlSpec['layout_' + newType])) {
+ if(!(propertyName in styleSpec.latest['layout_' + newType])) {
delete changedLayoutProps[propertyName]
}
})
diff --git a/src/libs/style.js b/src/libs/style.js
index 8edc3cf..cf2cff6 100644
--- a/src/libs/style.js
+++ b/src/libs/style.js
@@ -1,6 +1,5 @@
import React from 'react';
-import spec from 'mapbox-gl-style-spec/reference/latest.min.js'
-import derefLayers from 'mapbox-gl-style-spec/lib/deref'
+import deref from '@mapbox/mapbox-gl-style-spec/deref'
import tokens from '../config/tokens.json'
// Empty style is always used if no style could be restored or fetched
@@ -37,7 +36,7 @@ function ensureHasNoInteractive(style) {
function ensureHasNoRefs(style) {
const derefedStyle = {
...style,
- layers: derefLayers(style.layers)
+ layers: deref(style.layers)
}
return derefedStyle
}