-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview.html
98 lines (80 loc) · 2.26 KB
/
preview.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
<html>
<head>
<script type="text/javascript" src="http://polymaps.org/polymaps.min.js"></script>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin="" />
<script
src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
crossorigin=""></script>
<style type="text/css">
html, body {
height: 100%;
}
body {
margin: 0;
background: #E5E0D9;
}
#mapid{
width: 100%;
height: 100%;
}
.ev{
position: absolute;
z-index: 1000;
width: 48px;
left: 22px;
top: 22px;
}
</style>
</head>
<body>
<div id='mapid'></div>
<script>
/* globals L, location */
var mymap = L.map('mapid').setView([0, 0], 10)
L.tileLayer(`/?z={z}&x={x}&y={y}`, {
minZoom: 5,
maxZoom: 20,
attribution: 'Map data © Cryptovoxels',
id: 'cryptovoxels'
}).addTo(mymap)
var popup = L.popup()
function getCoord (x, z) {
const coords = []
if (x === 0) {
x = null
} else {
coords.push(x < 0 ? Math.abs(x) + 'W' : x + 'E')
}
if (z === 0) {
z = null
} else {
coords.push(z < 0 ? Math.abs(z) + 'S' : z + 'N')
}
return coords.length === 0 ? '/' : '/?coords=' + coords.join(',')
}
function onMapClick (e) {
// fixme: Where's the 3.5 from?
let x = Math.round(e.latlng.lng * 3.5)
let z = Math.round(e.latlng.lat * 3.5)
const c = getCoord(x, z)
const host = location.host.replace(/:.+/, '')
popup
.setLatLng(e.latlng)
.setContent(`
You clicked the map at ll(${e.latlng.toString()})
and w(${x},${z})
<br />
<br />
> <a href='//${host}:9000${c}'>Go here</a>
`)
.openOn(mymap)
}
mymap.on('click', onMapClick)
</script>
</body>
</html>