-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
35 lines (31 loc) · 895 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var mapnik = require('mapnik');
// register fonts and datasource plugins
//mapnik.register_default_fonts();
mapnik.register_default_input_plugins();
var map = new mapnik.Map(256, 256);
map.loadSync('test.xml');
//map.zoomAll();
map.zoomToBox(0, 0, 5, 5);
var im = new mapnik.Image(map.width, map.height);
map.render(im, function(err, im) {
if (err) console.log(err);
im.saveSync('map.png');
process.exit();
});
/*
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');
});
});
});
});
*/