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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { countries } from "https://esm.town/v/ingenieroariel/countries";
// View at https://ingenieroariel-bounds.express.val.run?country=UG
export async function bounds(req: express.Request, res: express.Response) {
const selected_country =
countries[req.query.country];
const name = selected_country[0];
const bbox = selected_country[1];
return res.send(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mobile tutorial - Leaflet</title>
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<style>
html, body {
height: 100%;
margin: 0;
}
.leaflet-container {
height: 400px;
width: 600px;
max-width: 100%;
max-height: 100%;
}
</style>
<style>body { padding: 0; margin: 0; } #map { height: 100%; width: 100vw; }</style>
</head>
<body>
<h1>Bounds for ${name} are [[${bbox[1]}, ${bbox[0]}], [${bbox[3]}, ${
bbox[2]
}]]</h1>
<div id='map'></div>
<script>
var map = L.map('map').fitWorld();
var bounds = [[${bbox[1]}, ${bbox[0]}], [${bbox[3]}, ${bbox[2]}]];
var tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var boundingBox = L.rectangle(bounds, {color: "#ff7800", weight: 1});
map.addLayer(boundingBox);
map.setView(boundingBox.getBounds().getCenter());
map.fitBounds(boundingBox.getBounds());
</script>
</body>
</html>
`);
}