Class: CartoCSS

SuperMap.CartoCSS

The CartoCSS parsing class,The main function is to parse the CartoCSS string into a shader attribute style object of CartoCSS.

new SuperMap.CartoCSS(cartoStr)

CartoCSS.js, line 4
Name Type Description
cartoStr string

CartoCSS stylesheet string.

Example
var cartocss = "@provinceLineColor:#ddd;
                #China_Provinces_L___China400{
                     line-dasharray:10,10;
                     line-color:@provinceLineColor;
                     line-width:1;
                }";
new SuperMap.CartoCSS(cartocss);

Members

cartoStr

CartoCSS stylesheet string.

parser

The parser.

ruleSet

CartoCSS rule object.

shaders

Carto shaders set.

Methods

destroy()

CartoCSS.js, line 1046

CartoCSS parser for parsing objects, used to destroy CartoCSS parsing objects.

getParser()

CartoCSS.js, line 63

Get CartoCSS parser.

getShaders(){Array}

CartoCSS.js, line 1017

Get CartoCSS shaders.

Returns:
Type Description
Array Shaders.
Example
//The structure of shaders is probably as follows:
  var shaders=[
  {
      attachment:"one",
      elements:[],
      zoom:23,
      length:2,
      0:{property:"line-color",value:function(attribute,zoom){var _value=null;if(zoom){_value="#123456"}return _vlaue;}},
      1:{preoperty:"line-width",value:function(attribute,zoom){var _value=null;if(zoom){_value=3}return _vlaue;}}
  },
  {
      attachment:"two",
      elements:[],
      zoom:23,
      length:2,
      0:{property:"polygon-color",value:function(attribute,zoom){var _value=null;if(zoom){_value="#123456"}return _vlaue;}},
      1:{property:"line-width",value:function(attribute,zoom){var _value=null;if(zoom){_value=3}return _vlaue;}}
  }
  ];

parse(){Object}

CartoCSS.js, line 873

Using the parse function inside the CartoCSS parser, transform the CartoCSS stylesheet string into a CartoCSS rule set.

Returns:
Type Description
Object CartoCSS rule set.

toShaders(){Array}

CartoCSS.js, line 885

Transform the cartoCSS rule set to the shaders.

Returns:
Type Description
Array The cartoCSS shaders set.