Created
June 13, 2011 22:18
-
-
Save springmeyer/1023868 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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