Skip to content

Commit

Permalink
Simplified JS example on frontpage
Browse files Browse the repository at this point in the history
I suggest to remove error handling and logging. This example should get the basic idea across, not distract with production bloat.
  • Loading branch information
Florian Letsch committed Oct 15, 2016
1 parent c32099b commit c0dbe28
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions _layouts/01_splash.html
Expand Up @@ -125,22 +125,15 @@ <h2 class="med-news"><a href="{{site.baseurl}}{{ post1-url }}"> {{ post1-title }
{% highlight js %}
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.load("./test/stylesheet.xml", function(err, map) {
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");
});
map.render(im, function(err, im) {
im.encode("png", function(err, buffer) {
fs.writeFile("map.png", buffer);
});
});
});
Expand Down

0 comments on commit c0dbe28

Please sign in to comment.