-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
99 lines (93 loc) · 3.61 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
<!DOCTYPE html>
<html>
<head>
<title>Earthbound Narrative Flowchart</title>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css">
<script src="https://cdn.rawgit.com/ardhi/Leaflet.MousePosition/master/src/L.Control.MousePosition.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdn.rawgit.com/ardhi/Leaflet.MousePosition/master/src/L.Control.MousePosition.css">
<script type="text/javascript" src="followup-data.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-134639368-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-134639368-1');
</script>
<style>
html, body, #map { width:100%; height:100%; margin:0; padding:0; z-index: 1; background: #ffffff; }
#slider{ position: absolute; top: 10px; right: 10px; z-index: 5; }
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var mapExtent = [0.00000000, -8704.00000000, 30208.00000000, 0.00000000];
var minZoom = 0;
var maxZoom = 7;
var maxRes = 1.00000000;
var minRes = Math.pow(2, maxZoom) * maxRes;;
var extents = [0.00000000, -8704.00000000, 30208.00000000, 0.00000000];
var crs = L.CRS.Simple;
crs.transformation = new L.Transformation(1, -extents[0], -1, extents[3]);
crs.scale = function(zoom) {
return Math.pow(2, zoom) / minRes;
};
crs.zoom = function(scale) {
return Math.log(scale * minRes) / Math.LN2;
};
var map = new L.Map('map', {
maxZoom: maxZoom,
minZoom: minZoom,
crs: crs
});
L.tileLayer('{z}/{x}/{y}.png', {
minZoom: minZoom, maxZoom: maxZoom,
attribution: '<a href="https://github.com/cocoatoucher/earthbound-narrative">Earthbound Narrative Flowchart</a>',
noWrap: true,
tms: false
}).addTo(map);
map.fitBounds([
crs.unproject(L.point(mapExtent[2], mapExtent[3])),
crs.unproject(L.point(mapExtent[0], mapExtent[1]))
]);
function style(feature) {
return {
weight: 2,
opacity: 1,
color: 'clear',
fillOpacity: 0.4,
fillColor: 'blue'
};
}
function zoomToFeature(e) {
var target = e.target;
var feature = target.feature;
var targetProperties = feature.properties;
if (targetProperties.type === "followup") {
var corner1 = L.latLng(targetProperties.destination[0][0], targetProperties.destination[0][1]),
corner2 = L.latLng(targetProperties.destination[1][0], targetProperties.destination[1][1]),
bounds = L.latLngBounds(corner1, corner2);
map.fitBounds(bounds);
} else if (targetProperties.type === "map") {
var url = targetProperties.url;
window.open(url);
}
}
function onEachFeature(feature, layer) {
layer.on({
click: zoomToFeature
});
}
L.geoJson(followUpData, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);
L.control.mousePosition().addTo(map)
</script>
</body>
</html>