JSPM

  • Created
  • Published
  • Downloads 314
  • Score
    100M100P100Q76579F
  • License MIT

Transform cartocss into a draw tangram object.

Package Exports

  • tangram-cartocss

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tangram-cartocss) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Tangram-cartocss build

Conditional Style

Installation & usage

me$ npm i tangram-cartocss
// or
me$ yarn add tangram-cartocss
import CCSS from 'tangram-cartocss';

API

CCSS object

.carto2Draw

/**
 * Transform a cartocss string into a Tangram draw layer config object.
 * @param  {String} cartocss   string with cartocsm
 * @return {Object}            return a draw object with the style functions
 */
var cartocss = '#layer { polygon-fill: '#DF038A';}';

var draw = CCSS.carto2draw(cartocss);

draw == {
  polygons: {
    color: 'function () { var toRet = null;  toRet = "#DF038A";  return toRet;}'
  }
};

How to try with tangram

var cartocss = `
  #layer {
   marker-fill: red;
   marker-width: 10;
  }
  `;
scene_layer = Tangram.leafletLayer({
  scene: 'demos/scene.yaml',
  logLevel: 'debug'
}).addTo(map);

map.setView( [ 40.7, -74.009 ], 14 );
  scene_layer.scene.config.layers.buildings.draw = CCSS.carto2Draw(cartocss);
  scene_layer.scene.updateConfig();
});