Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mbtiles
var app = require('express').createServer(),
mbtiles = require('mbtiles'),
tilelive = new (require('tilelive').Server)(mbtiles);
app.get('/:z/:x/:y.*', function(req, res) {
var options = {
x: req.param('x'),
y: req.param('y'),
z: req.param('z'),
format: req.params[0],
datasource: __dirname + '/example.mbtiles'
};
tilelive.serve(options, function(err, data) {
if (!err) {
res.send.apply(res, data);
} else {
res.send('Tile rendering error: ' + err + '\n');
}
});
});
console.log('Listening on port: ' + 8888);
app.listen(8888);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment