flat-geo-css
v1.0.6
Published
flat-geo-css
Downloads
676
Readme
flat-geo-css
This package translates a flat geocss encoding to a json structure and vice versa.
Examples
- From geocss encoding to json structure example
import flatGeoCSS from 'flat-geo-css';
const geoCSSJSON = flatGeoCSS.read(`
@mode 'Flat';
* {
fill: #aaff33;
stroke: #333333;
stroke-width: 4;
}`);
// geoCSSJSON output
/*
{
"directive": {
"@mode": "Flat"
},
"rules": [
{
"group": 1,
"properties": {
"fill": [
"hex",
"#aaff33"
],
"stroke": [
"hex",
"#333333"
],
"stroke-width": 4
},
"selector": "*"
}
]
}
*/
- From json structure to geocss encoding example
import flatGeoCSS from 'flat-geo-css';
const style = flatGeoCSS.write({
"directive": {
"@mode": "Flat"
},
"rules": [
{
"group": 1,
"properties": {
"fill": [
"hex",
"#aaff33"
],
"stroke": [
"hex",
"#333333"
],
"stroke-width": 4
},
"selector": "*"
}
]
});
// style output
/*
@mode 'Flat';
* {
fill: #aaff33;
stroke: #333333;
stroke-width: 4;
}
*/