forked from denschub/c3map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (59 loc) · 1.94 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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Usermap - 31st Chaos Communication Congress</title>
<link rel="stylesheet" href="leaflet/leaflet.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
</style>
<script src="leaflet/leaflet.js"></script>
<script>
var app = {
map: null,
popup: L.popup()
};
function onMapClick(e) {
var location_link = window.location.href.replace(window.location.hash,"") + "#/loc/" + e.latlng.lat + '/' + e.latlng.lng;
app.popup.setLatLng(e.latlng)
.setContent('<a href="' + location_link + '">Link to this location</a>')
.openOn(app.map);
}
function addHashLocationMarker() {
if(window.location.hash.indexOf("loc") !== -1) {
var hash = window.location.hash.split('/');
L.marker([hash[2], hash[3]]).addTo(app.map)
.bindPopup("Shared Location").openPopup();
app.map.setView([hash[2], hash[3]], 3);
}
}
document.addEventListener("DOMContentLoaded", function() {
app.map = L.map("map", {
maxBounds: L.latLngBounds(
L.latLng(-85, -180),
L.latLng(85, 180)
)
}).setView([1,1], 2);
L.tileLayer("tiles/{z}/{x}/{y}.jpg", {
minZoom: 0,
maxZoom: 5,
tileSize: 256,
continuousWorld: true,
attribution: '<a href="https://github.com/denschub/c3map/blob/master/LICENSE">c3map license information</a>'
}).addTo(app.map);
addHashLocationMarker();
app.map.on("click", onMapClick);
});
window.addEventListener("hashchange", addHashLocationMarker);
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>