# Node Mapnik

Provides a set of bindings to Mapnik for Node.js

Star

Node Mapnik is based on Mapnik, a C++ library created for rendering images and vector tiles from custom geographic data sources.

Current version: 3.5.0

## Installation

Node Mapnik is registered in npm as a module. You can install it with the following command.

    npm install --save mapnik

## Usage

Render a map from a stylesheet:

    var mapnik = require('mapnik');
    var fs = require('fs');

    // register fonts and datasource plugins
    mapnik.register_default_fonts();
    mapnik.register_default_input_plugins();

    var map = new mapnik.Map(256, 256);
    map.load('./test/stylesheet.xml', function(err,map) {
        if (err) throw err;
        map.zoomAll();
        var im = new mapnik.Image(256, 256);
        map.render(im, function(err,im) {
          if (err) throw err;
          im.encode('png', function(err,buffer) {
              if (err) throw err;
              fs.writeFile('map.png',buffer, function(err) {
                  if (err) throw err;
                  console.log('saved map image to map.png');
              });
          });
        });
    });

### API Reference

3.5 (latest)
3.4