-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·43 lines (38 loc) · 1.09 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const express = require('express');
const Map = require('./index.js');
let app = express();
app.get('/snapshot/:options', async (req, res) => {
const opt = req.params.options.split(',');
console.log(opt[4]);
const format = opt[4].match(/(\d+)x(\d+)\.(png)/);
console.log(format)
const options = {
zoom: opt[1],
center: [opt[3], opt[2]],
width: format[1],
height: format[2],
format: format[3],
};
console.log(options);
const map = new Map({
ratio: 1,
src: opt[0],
});
await map.render(
req.query.title,
// {zoom: 7, center: [-91.6714, 30.2038], width, height},
options,
(snapshot) => {
res.writeHead(200, {'Content-Type': 'image/png'});
// res.write();
res.end(snapshot);
}
);
// osm-intl,8,30.2038,-91.6714,800x600.png?
// lang=en&
// domain=commons.wikimedia.org
// &title=Data%3AInterstate+10+in+Louisiana.map
});
app.listen(3000, () => {
console.log("The server is listening on http://localhost:3000");
});