Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
CartoCSS (short: Carto) is a language for map design. It is similar in syntax to CSS, but builds upon it with specific abilities to filter map data and by providing things like variables. It targets the Mapnik renderer and is able to generate Mapnik XML and a JSON variant of Mapnik XML. It can run from the command line or in the browser.
Carto is an evolution of the Cascadenik idea and language, with an emphasis on speed and flexibility.
The best place to start is to review the CartoCSS documentation.
Tutorials like the Mapbox Getting started with CartoCSS guide are a great place to start to learn the basics of CartoCSS.
For more advanced topics see the Studio style quickstart guide and Studio style manual. The links below reference the Tilemill application, which preceded Mapbox Studio Classic, but still contain useful and relevant information.
If you are using a map design application like Kosmtik, Mapbox Studio Classic or Tilemill you already have CartoCSS installed and might be more interested in the language reference.
Else you can install the carto
binary with NPM by running:
npm install -g carto
You should consider using a Node.js version manager like NVM. Optionally you may also want to install millstone which is required for resolving data in the same way as Mapbox Studio Classic does:
npm install -g millstone
Having millstone
installed specifically enable support for localizing external resources (URLs and local files) referenced in your mml file, and detecting projections (using node-srs)
Now that Carto is installed you should have a carto
command line tool available that can be run on a CartoCSS project:
carto project.mml > mapnik.xml
Available parameters:
mapnik
and json
(default: mapnik
)Alternatively, Carto can be used from JavaScript.
The Renderer
interface is the main API for developers, and it takes an MML file as a string as input.
// defined variables:
// - input (the name or identifier of the file being parsed)
var carto = require('carto');
try {
var data = fs.readFileSync(input, 'utf-8');
var mml = new carto.MML({});
mml.load(path.dirname(input), data, function (err, data) {
var output = {};
if (!err) {
output = new carto.Renderer({
filename: input
}).render(data);
}
if (output.msg) {
output.msg.forEach(function (v) {
if (v.type === 'error') {
console.error(carto.Util.getMessageToPrint(v));
}
else if (v.type === 'warning') {
console.warn(carto.Util.getMessageToPrint(v));
}
});
}
// output content (if no errors)
if (output.data) {
console.log(output.data);
}
});
} catch (err) {
// program failures
...
}
If you want to use CartoCSS within the browser you should not use MML loading via carto.MML.load
.
Instead you should supply the JSON of the MML including the Stylesheet strings directly to carto.Renderer.render
.
To install, download or clone this repository, then copy the vim-carto
directory located at build/vim-carto
to your ~/.vim
directory.
cp build/vim-carto/* ~/.vim -R
CartoCSS is based on less.js, a CSS compiler written by Alexis Sellier.
See also a list of dependencies.
1.2.0
FAQs
Mapnik Stylesheet Compiler
The npm package carto receives a total of 617 weekly downloads. As such, carto popularity was classified as not popular.
We found that carto demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.