Skip to content

Instantly share code, notes, and snippets.

@veltman
Created December 30, 2015 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veltman/7d270a218abd7185bf82 to your computer and use it in GitHub Desktop.
Save veltman/7d270a218abd7185bf82 to your computer and use it in GitHub Desktop.
Naive Mapzen vector tiles proxy
var express = require("express"),
cors = require("cors"),
request = require("request"),
path = require("path"),
app = express();
// For ports
app.use(cors());
app.get("*",function(req, res){
request.get("https://" + path.join("vector.mapzen.com",req.url),function(err,r,body){
res.status(r.statusCode);
if (r.statusCode !== 200) {
return res.send(body || "");
}
var topo = JSON.parse(body);
if ("buildings" in topo.objects) {
topo.objects.buildings.geometries.forEach(function(geom){
if (!geom.properties.id) {
return;
}
// Add some properties here
});
}
res.json(topo);
});
});
app.listen(8888);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment