-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
56 lines (49 loc) · 1.8 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
<!doctype html>
<html>
<head>
<script>
L_DISABLE_3D = true;
</script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>
<style>
#mapid {
height: 100vh;
}
html, body {
margin: 0;
}
</style>
</head>
<body>
<div id="mapid"></div>
<script>
const chunkSizeInTiles = 32
const fontWidth = 9
const fontHeight = 9
const chunkWidthInPixels = chunkSizeInTiles * fontWidth
const chunkHeightInPixels = chunkSizeInTiles * fontHeight
const mapWidthInTiles = 129 * 16
const mapHeightInTiles = 129 * 16
const mapWidthInPixels = mapWidthInTiles * fontWidth
const mapHeightInPixels = mapHeightInTiles * fontHeight
const maxZoom = 7
const rootChunkNumTiles = Math.pow(2, maxZoom) * chunkSizeInTiles
const mapWidthAsProportionOfRootChunk = mapWidthInTiles / rootChunkNumTiles
const mapHeightAsProportionOfRootChunk = mapHeightInTiles / rootChunkNumTiles
const mymap = L.map('mapid', {
crs: L.CRS.Simple,
})
mymap.setMaxZoom(maxZoom)
const bounds = [[-chunkHeightInPixels*mapHeightAsProportionOfRootChunk, 0], [0, chunkHeightInPixels*mapHeightAsProportionOfRootChunk]]
mymap.setMaxBounds(bounds)
mymap.setView([0, 0], 2)
L.tileLayer('./tiles/{z}/{x}/{y}.png', {
maxZoom,
noWrap: true,
tileSize: L.point(chunkWidthInPixels, chunkHeightInPixels),
bounds,
}).addTo(mymap)
</script>
</body>
</html>