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.
Daniel García Aubert
85881d99dd
|
6 years ago | |
---|---|---|
bin | 9 years ago | |
build | 10 years ago | |
dist | 7 years ago | |
docs | 10 years ago | |
docs-generator | 9 years ago | |
lib/carto | 7 years ago | |
man | 10 years ago | |
test | 7 years ago | |
.gitignore | 8 years ago | |
.npmignore | 13 years ago | |
.travis.yml | 6 years ago | |
CHANGELOG.carto.md | 6 years ago | |
CHANGELOG.md | 10 years ago | |
DEVELOPING.md | 10 years ago | |
LICENSE | 15 years ago | |
Makefile | 10 years ago | |
README.md | 9 years ago | |
package-lock.json | 6 years ago | |
package.json | 6 years ago |
README.md
CartoCSS
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