-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
131 lines (125 loc) · 3.74 KB
/
index.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OHM Prod-Stag tiler</title>
<link
href="https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.css"
rel="stylesheet"
/>
<script src="https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.js"></script>
<script src="app.js"></script>
<style>
body {
margin: 0;
}
#navbar {
position: absolute;
width: 100%;
height: 40px;
top: 0;
z-index: 222;
display: flex;
align-items: center;
background-color: #000;
color: white;
}
#navbar > div {
flex: 1;
text-align: center;
}
#navbar > div:first-child {
text-align: left;
margin-left: 10%;
}
#navbar > div:last-child {
text-align: right;
margin-right: 10%;
}
#map {
position: fixed;
top: 0px;
left: 50%;
transform: translateX(-50%);
z-index: 20000;
height: 150px;
width: 150px;
}
#iframeContainer {
display: flex;
flex-direction: row;
height: 100vh;
width: 100%;
}
iframe {
flex-grow: 1;
width: 100%;
height: 100vh;
}
</style>
</head>
<body>
<div
id="navbar"
style="display: flex; justify-content: space-between; width: 100%"
>
<div>
<a id="href_prod" href="#" target="_blank"
style="color: #2776CA; text-decoration: none;" ><h5 id="title_prod">Tiler Production</h5></a
>
</div>
<div>
<a id="href_staging" href="#" target="_blank"
style="color: #2776CA; text-decoration: none;" ><h5 id="title_staging">Tiler Staging</h5></a
>
</div>
</div>
<div id="iframeContainer">
<iframe
id="vtile_prod"
src="https://vtiles.openhistoricalmap.org"
></iframe>
<iframe id="vtile_staging" src="https://vtiles.staging.openhistoricalmap.org"></iframe>
</div>
<div id="map"></div>
<script>
mapboxgl.accessToken =
"pk.eyJ1IjoicnViZW4iLCJhIjoiY2xubDNiaHFwMXZjaDJtcmk3eW44NXJkaiJ9.vG8Vmq6bgcmiKKtmuV_fjw";
var map = new mapboxgl.Map({
container: "map",
style: "mapbox://styles/mapbox/streets-v11",
center: [0, 0],
zoom: 2,
hash: true,
});
const iframe_vtileProd = document.getElementById("vtileProd");
const iframe_vtileStaging = document.getElementById("vtileStaging");
const title_vtileProd = document.getElementById("title_prod");
const title_vtilesStaging = document.getElementById("title_staging");
function frameUpdate(enviroment, zoom, x, y) {
const iframe = document.getElementById("vtile_" + enviroment);
const title = document.getElementById("title_" + enviroment);
const aTag = document.getElementById("href_" + enviroment);
const url = iframe.src.split("#")[0];
const newUrl =
url + "#" + zoom.toFixed(2) + "/" + x.toFixed(2) + "/" + y.toFixed(2);
iframe.src = newUrl;
title.textContent = newUrl;
aTag.href = newUrl;
}
map.on("moveend", function () {
const center = map.getCenter();
frameUpdate("prod", map.getZoom(), center.lat, center.lng);
frameUpdate("staging", map.getZoom(), center.lat, center.lng);
});
map.on("load", function () {
const params = getMapParametersFromCurrentUrl();
if (params) {
frameUpdate("prod", params.zoom, params.x, params.y);
frameUpdate("staging", params.zoom, params.x, params.y);
}
});
</script>
</body>
</html>