You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Go to file
Daniel García Aubert 85881d99dd
Release 0.15.1-cdb5
6 years ago
bin Drop xml2js and thus mml2json. 9 years ago
build update to mapbox 0.0.11 master 10 years ago
dist Dist files 7 years ago
docs Re-generate 10 years ago
docs-generator Update less link 9 years ago
lib/carto adds shield-placement-type to torque-reference 7 years ago
man update to mapbox 0.0.11 master 10 years ago
test Cover 'numbers' type, like in line-dasharray 7 years ago
.gitignore Ignore idea based configurations 8 years ago
.npmignore Getting ignores right, tagging 0.4.4 13 years ago
.travis.yml Drop support for oldest Node.js versions and support latest LTS releases 6 years ago
CHANGELOG.carto.md Release 0.15.1-cdb5 6 years ago
CHANGELOG.md call this branch v0.14.0 10 years ago
DEVELOPING.md update to mapbox 0.0.11 master 10 years ago
LICENSE moved to apache license 15 years ago
Makefile adds Makefile to produce uncompressed and minified dists 10 years ago
README.md Use build status from cartodb repo 9 years ago
package-lock.json Prepare next release version 6 years ago
package.json Prepare next release version 6 years ago

README.md

CartoCSS

Build Status

Is as stylesheet renderer for javascript, It's an evolution of the Mapnik renderer from Mapbox. Please, see original Mapbox repo for more information and credits

Quick Start

// shader is a CartoCSS object

var cartocss = [
    '#layer {',
    ' marker-width: [property]',
    ' marker-fill: red',
    '}'
].join('')
var shader = new carto.RendererJS().render(cartocss);
var layers = shader.getLayers()
for (var i = 0; i < layers.length; ++i) {
    var layer = layers[i];
    console.log("layer name: ", layer.fullName())
    console.log("- frames: ", layer.frames())
    console.log("- attachment: ", layer.attachment())

    var layerShader = layer.getStyle({ property: 1 }, { zoom: 10 })
    console.log(layerShader['marker-width']) // 1
    console.log(layerShader['marker-fill']) // #FF0000
}

API

RendererJS

render(cartocss)

CartoCSS

compiled cartocss object

getLayers

return the layers, an array of CartoCSS.Layer object

getDefault

return the default layer (CartoCSS.Layer), usually the Map layer

findLayer(where)

find a layer using where object.

shader.findLayer({ name: 'test' })

CartoCSS.Layer

getStyle(props, context)

return the evaluated style: - props: object containing properties needed to render the style. If the cartocss style uses some variables they should be passed in this object - context: rendering context variables like zoom or animation frame

Reference Documentation