Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created June 13, 2011 22:18
Show Gist options
  • Save springmeyer/1023868 to your computer and use it in GitHub Desktop.
Save springmeyer/1023868 to your computer and use it in GitHub Desktop.
/* new map loading api in node-mapnik */
var map = new mapnik.Map(256,256);
// map.load is now async and therefore returns modified map in callback
// it could also not return it, since 'map' is already defined
map.load("stylesheet.xml",{strict:true},function(err,map) {
// do something with map...
})
/* new rendering api in node-mapnik */
// images
var im = new mapnik.Image(map.width,map.height)
// first arg is now the image
// and image is also returned in callback
map.render(im, {scale:1}, function(err, image) {
var buffer = im.encode('png');
// do something with buffer
});
// grids
var grid = new mapnik.Grid(map.width,map.height,{key:'SOME_ID'})
// first arg is now the grid
// and grid is also returned in callback
map.render(im, {scale:1}, function(err, grid) {
var json = grid.encode('utf');
// do something with json grid
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment