Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec schema #459

Merged
merged 4 commits into from
Jun 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debug/style.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1",
"version": 2,
"sources": {
"mapbox.mapbox-streets-v5": {
"type": "vector",
Expand Down
4 changes: 2 additions & 2 deletions js/style/calculatedstyle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var reference = require('mapbox-gl-style-spec');
var reference = require('mapbox-gl-style-spec').v2;

module.exports = CalculatedStyle;

Expand All @@ -11,7 +11,7 @@ function CalculatedStyle() {}
function addDefaultValues() {
var style = reference.style;
for (var prop in style) {
var value = style[prop]['default-value'];
var value = style[prop]['default'];
if (value !== undefined) {
CalculatedStyle.prototype[prop] = value;
}
Expand Down
10 changes: 5 additions & 5 deletions js/style/styledeclaration.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var util = require('../util/util.js'),
reference = require('mapbox-gl-style-spec'),
reference = require('mapbox-gl-style-spec').v2,
parseCSSColor = require('csscolorparser').parseCSSColor;

module.exports = StyleDeclaration;
Expand All @@ -18,7 +18,7 @@ function StyleDeclaration(prop, value, constants) {
value = constants[value];
}

this.value = this.parseValue(value, propReference.type);
this.value = this.parseValue(value, propReference.type, propReference.values);
this.prop = prop;
this.type = propReference.type;
this.constants = constants;
Expand All @@ -32,7 +32,7 @@ StyleDeclaration.prototype.calculate = function(z) {
return typeof this.value === 'function' ? this.value(z) : this.value;
};

StyleDeclaration.prototype.parseValue = function(value, type) {
StyleDeclaration.prototype.parseValue = function(value, type, values) {
if (type === 'color') {
return parseColor(value);
} else if (type === 'number') {
Expand All @@ -43,8 +43,8 @@ StyleDeclaration.prototype.parseValue = function(value, type) {
return String(value);
} else if (type === 'array') {
return parseNumberArray(value);
} else if (Array.isArray(type)) {
return type.indexOf(value) >= 0;
} else if (type === 'enum' && Array.isArray(values)) {
return values.indexOf(value) >= 0;
} else {
console.warn(type + ' is not a supported property type');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"csscolorparser": "~1.0.2",
"geojson-rewind": "~0.1.0",
"mapbox-gl-style-spec": "0.0.0",
"mapbox-gl-style-spec": "0.0.1",
"pbf": "0.0.1",
"queue-async": "^1.0.7",
"rbush": "~1.3.2",
Expand Down