-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sprite@2x to json and png tile routes
- Loading branch information
Dianna Faulk
committed
Oct 27, 2019
1 parent
371287a
commit b407da0
Showing
1 changed file
with
7 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,17 @@ const app = express(); | |
|
||
app.use(cors()); | ||
|
||
app.get("/tiles/:version/tiles/:z/:x/:y.pbf", function(req, res) { | ||
app.get("/tiles/:version/tiles/:z/:x/:y.pbf", function (req, res) { | ||
const { z, x, y } = req.params; | ||
new MBTiles(path.join(__dirname, "tiles", "tiles.mbtiles"), function( | ||
new MBTiles(path.join(__dirname, "tiles", "tiles.mbtiles"), function ( | ||
err, | ||
mbtiles | ||
) { | ||
if (err) { | ||
res.header("Content-Type", "text/plain"); | ||
res.status(500).send(`Tile error: ${err}`); | ||
} else { | ||
mbtiles.getTile(z, x, y, function(err, tile, headers) { | ||
mbtiles.getTile(z, x, y, function (err, tile, headers) { | ||
if (err) { | ||
res.header("Content-Type", "text/plain"); | ||
res.status(404).send(`Tile error ${err}`); | ||
|
@@ -31,13 +31,13 @@ app.get("/tiles/:version/tiles/:z/:x/:y.pbf", function(req, res) { | |
}); | ||
}); | ||
|
||
const themeHandler = function(req, res) { | ||
const themeHandler = function (req, res) { | ||
let theme = req.params.theme; | ||
if (!theme.endsWith(".json")) { | ||
theme = theme + ".json"; | ||
} | ||
const filePath = path.join(__dirname, "themes", theme); | ||
fs.readFile(filePath, "utf8", function(err, file) { | ||
fs.readFile(filePath, "utf8", function (err, file) { | ||
if (err) { | ||
res.status(500); | ||
res.json({ status: 500, message: `Could not load theme: ${err}` }); | ||
|
@@ -55,11 +55,11 @@ const themeHandler = function(req, res) { | |
app.get("/tiles/styles/:version/:theme", themeHandler); | ||
app.get("/tiles/:version/:theme", themeHandler); | ||
|
||
app.get("/tiles/styles/:version/:theme/sprite.json", function(req, res) { | ||
app.get(["/tiles/styles/:version/:theme/sprite.json", "/tiles/styles/:version/:theme/[email protected]"], function (req, res) { | ||
res.json({}); | ||
}); | ||
|
||
app.get("/tiles/styles/:version/:theme/sprite.png", function(req, res) { | ||
app.get(["/tiles/styles/:version/:theme/sprite.png", "/tiles/styles/:version/:theme/[email protected]"], function (req, res) { | ||
const reader = fs.createReadStream( | ||
path.join(__dirname, "themes", "sprite.png") | ||
); | ||
|