If you want to use node-mapnik
in an app with concurrency, you'll want to use
a map pool. Concurrently using a single map instance can crash your app,
and several map instances will give you a significant speedup. mapnik-pool
manages a generic-pool
of mapnik.Map
instances so you don't have to.
npm install --save mapnik-pool
mapnik-pool
is a peerDependency
of node-mapnik
: you bring your own Mapnik version, as long as its ~1.0.0
.
var mapnik = require('mapnik'),
mapnikPool = require('mapnik-pool')(mapnik),
fs = require('fs');
var pool = mapnikPool.fromString(fs.readFileSync('mymap.xml', 'utf8'));
pool.acquire(function(err, map) {
// pooled map
});
str
: a Mapnik XML stringinitOptions
: options for initialization. Currently,size
for map,bufferSize
. Default{ size: 256 }
mapOptions
: options for thefromString
method.