Moved to using @mapbox/mapbox-gl-style-spec

This commit is contained in:
orangemug
2017-04-10 13:29:57 +01:00
parent ac8ae0da66
commit c3174a0c72
19 changed files with 52 additions and 56 deletions

View File

@@ -1,7 +1,7 @@
import diffStyles from 'mapbox-gl/src/style-spec/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(' '))
}

View File

@@ -1,6 +1,6 @@
import GlSpec from 'mapbox-gl/src/style-spec/reference/latest'
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)

View File

@@ -1,16 +1,16 @@
import GlSpec from 'mapbox-gl/src/style-spec/reference/latest'
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]
}
})

View File

@@ -1,6 +1,5 @@
import React from 'react';
import spec from 'mapbox-gl/src/style-spec/reference/latest'
import derefLayers from 'mapbox-gl/src/style-spec/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
}