Last active
May 18, 2023 07:51
Revisions
-
Manuel Roth revised this gist
May 11, 2016 . No changes.There are no files selected for viewing
-
Manuel Roth revised this gist
May 11, 2016 . No changes.There are no files selected for viewing
-
Manuel Roth revised this gist
May 11, 2016 . No changes.There are no files selected for viewing
-
Manuel Roth revised this gist
May 11, 2016 . 1 changed file with 1 addition and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,12 +19,7 @@ app.get('/:source/:z/:x/:y.pbf', function(req, res) { res.set({"Content-Type": "text/plain"}); res.status(404).send('Tile rendering error: ' + err + '\n'); } else { res.set(header); res.send(tile); } }); -
Manuel Roth revised this gist
May 11, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,7 @@ var header = { "Content-Encoding":"gzip" }; // Route which handles requests like the following: /<mbtiles-name>/0/1/2.pbf app.get('/:source/:z/:x/:y.pbf', function(req, res) { new MBTiles(p.join(__dirname, req.params.source + '.mbtiles'), function(err, mbtiles) { mbtiles.getTile(req.params.z, req.params.x, req.params.y, function(err, tile, headers) { @@ -31,6 +32,6 @@ app.get('/:source/:z/:x/:y.pbf', function(req, res) { }); }); // Starts up the server on port 3000 console.log('Listening on port: ' + 3000); app.listen(3000); -
Manuel Roth created this gist
May 11, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ var express = require("express"), app = express(), MBTiles = require('mbtiles'), p = require("path"); // Enable CORS and set correct mime type/content encoding var header = { "Access-Control-Allow-Origin":"*", "Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept", "Content-Type":"application/x-protobuf", "Content-Encoding":"gzip" }; app.get('/:source/:z/:x/:y.pbf', function(req, res) { new MBTiles(p.join(__dirname, req.params.source + '.mbtiles'), function(err, mbtiles) { mbtiles.getTile(req.params.z, req.params.x, req.params.y, function(err, tile, headers) { if (err) { res.set({"Content-Type": "text/plain"}); res.status(404).send('Tile rendering error: ' + err + '\n'); } else { res.set({ "Access-Control-Allow-Origin":"*", "Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept", "Content-Type":"application/x-protobuf", "Content-Encoding":"gzip" }); res.send(tile); } }); if (err) console.log("error opening database"); }); }); // start up the server console.log('Listening on port: ' + 3000); app.listen(3000);