diff --git a/app/map_styles/polygon.xml b/app/map_styles/polygon.xml index 4b70afd4..3e38f0f6 100644 --- a/app/map_styles/polygon.xml +++ b/app/map_styles/polygon.xml @@ -1,25 +1,25 @@ - + diff --git a/app/src/frontend/map.js b/app/src/frontend/map.js index 7cc660b0..17fc19c7 100644 --- a/app/src/frontend/map.js +++ b/app/src/frontend/map.js @@ -89,6 +89,10 @@ class ColouringMap extends Component { : null; + const base_layer_url = (this.state.theme === 'light')? + `/tiles/base_light/{z}/{x}/{y}.png` + : `/tiles/base_night/{z}/{x}/{y}.png` + return ( + { dataLayer } { highlightLayer } diff --git a/app/src/tileserver.js b/app/src/tileserver.js index 88bcb3e3..8ba71d71 100644 --- a/app/src/tileserver.js +++ b/app/src/tileserver.js @@ -11,10 +11,41 @@ import { strictParseInt } from './parse'; const router = express.Router() // basic geometry tiles -router.get('/outline/:z/:x/:y.png', function(req, res) { +router.get('/base_light/:z/:x/:y.png', function(req, res) { const bbox = get_bbox(req.params) - const table_def = 'geometries' - const style_def = ['polygon'] + const table_def = `( + SELECT + b.location_number as location_number, + g.geometry_geom + FROM + geometries as g, + buildings as b + WHERE + g.geometry_id = b.geometry_id + ) as outline` + const style_def = ['base_light'] + render_tile(bbox, table_def, style_def, function(err, im) { + if (err) throw err + + res.writeHead(200, {'Content-Type': 'image/png'}) + res.end(im.encodeSync('png')) + }) +}); + +// dark theme +router.get('/base_night/:z/:x/:y.png', function(req, res) { + const bbox = get_bbox(req.params) + const table_def = `( + SELECT + b.location_number as location_number, + g.geometry_geom + FROM + geometries as g, + buildings as b + WHERE + g.geometry_id = b.geometry_id + ) as outline` + const style_def = ['base_night'] render_tile(bbox, table_def, style_def, function(err, im) { if (err) throw err @@ -35,7 +66,6 @@ router.get('/highlight/:z/:x/:y.png', function(req, res) { const table_def = `( SELECT g.geometry_id = ${geometry_id} as focus, - b.location_number as location_number, g.geometry_geom FROM geometries as g,