forked from MrCheeze/botw-object-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboo.html
237 lines (216 loc) · 7.84 KB
/
boo.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<html>
<head>
<title>Breath of the Wild Object Map</title>
<meta charset="utf-8">
<script src='jquery-1.12.0.min.js'></script>
<link rel="stylesheet" href="leaflet.css" />
<link rel="stylesheet" href="MarkerCluster.css" />
<link rel="stylesheet" href="chosen.min.css" />
<script src="leaflet.js"></script>
<script src="list.min.js"></script>
<script src="leaflet.markercluster.js"></script>
<script src="chosen.jquery.min.js"></script>
<style>
body {
background: #3e443b;
color: #dadad3;
font-family: sans-serif;
font-size: small;
}
.leaflet-container {
background-color: rgba(255,0,0,0.0);
}
#botw_map {
display: inline-block;
height: 99%;
width: 70%;
}
#sidebar {
display: inline-block;
height: 99%;
width: 29%;
overflow: scroll;
white-space: nowrap;
}
#sidebar > .list li, #sidebar > .list {
list-style-type: none;
padding: 0;
}
#filter {
width: 300px;
}
.display-name {
font-style: italic;
}
.name-separator {
color: #8c8f87;
}
.internal-name {
font-family: "Courier New", Courier, monospace;
}
.itemName {
display: none;
}
.div-icon0 { border-radius: 50%; border: 1px solid #00FFFF; background: rgba(0,255,255,0.25)}
.div-icon1 { border-radius: 50%; border: 1px solid #FFFF00; background: rgba(255,255,0,0.25) }
.div-icon2 { border-radius: 50%; border: 1px solid #FF00FF; background: rgba(255,0,255,0.25) }
.div-icon3 { border-radius: 50%; border: 1px solid #FF6060; background: rgba(255,96,96,0.25) }
.div-icon4 { border-radius: 50%; border: 1px solid #60FF60; background: rgba(96,255,96,0.25) }
.div-icon5 { border-radius: 50%; border: 1px solid #6030FF; background: rgba(96,48,255,0.25) }
.div-icon6 { border-radius: 50%; border: 1px solid #40C0FF; background: rgba(64,192,255,0.25) }
.div-icon7 { border-radius: 50%; border: 1px solid #C0FF40; background: rgba(192,255,64,0.25) }
.div-icon8 { border-radius: 50%; border: 1px solid #FF40C0; background: rgba(255,64,192,0.25) }
.div-icon9 { border-radius: 50%; border: 1px solid #FFC040; background: rgba(255,192,64,0.25) }
.div-icon10 { border-radius: 50%; border: 1px solid #40FFC0; background: rgba(64,255,192,0.25) }
.div-icon11 { border-radius: 50%; border: 1px solid #C040FF; background: rgba(192,64,255,0.25) }
.div-icon12 { border-radius: 50%; border: 1px solid #FFFFFF; background: rgba(255,255,255,0.25) }
.big-icon {
border-width: 2px;
text-align: center;
color: #fff;
text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000;
height: 18px;
line-height: 18px;
}
a {
color: #09f;
}
</style>
</head>
<body>
<div id="botw_map"></div>
<div id="sidebar">
<div>
<select id="filter" data-placeholder="Filter by preset..." multiple></select><br>
<button id="selectAll" title="Select all filtered items" disabled>All</button><button id="selectNone" title="Deselect all filtered items">None</button>
<input type="text" class="search" title="Filter by name..." autocomplete="off"/>
</div>
<ul class="list"></ul>
</div>
<div>Note that many objects are dynamically generated and are not included in this data. For more BotW datamining, see my <a href="https://mrcheeze.github.io/">GitHub/Pastebin</a>.</div>
<script>
var map = L.map('botw_map', {
preferCanvas: true,
minZoom: -4,
maxZoom: 4,
center: [0, 0],
zoom: -4,
crs: L.CRS.Simple
});
var southWest = map.unproject([-6000, 5000], 0);
var northEast = map.unproject([6000, -5000], 0);
var bounds = new L.LatLngBounds(southWest, northEast);
L.imageOverlay('BotW-Map-Grid.png', bounds).addTo(map);
map.setMaxBounds(bounds);
var query = window.location.href.search('list=');
var locationfile = 'map_locations.js';
var ormarker = L.marker(
map.unproject([0, 0]),
{
icon: L.divIcon({className:'div-icon0'}),
title:'Origin'
});
var swmarker = L.marker(southWest,
{
icon: L.divIcon({className: 'div-icon1'}),
title: 'southWest'
});
map.addLayer(ormarker);
map.addLayer(swmarker);
if (query > 0) {
locationfile = window.location.href.substr(window.location.href.search('list=')+5) + '.js';
}
$.getScript(locationfile, function() {
var internal_names = Object.keys(locations).sort();
var listHtml = internal_names.map(renderListItem).join("");
$('#sidebar > ul').append(listHtml);
var icons = Array.from(Array(12).keys()).map(i => L.divIcon({className: 'div-icon' + i}));
var markers = {};
var markerClusterGroupOptions = {
removeOutsideVisibleBounds: true,
spiderfyOnMaxZoom: false,
disableClusteringAtZoom: 0,
animate: false,
maxClusterRadius: 20,
iconCreateFunction: function(cluster) {
var childMarkers = cluster.getAllChildMarkers();
var titleText = '';
var iconClassName = '';
if (childMarkers.length > 0) {
var childOptions = childMarkers[0].options;
titleText = childOptions.title;
if (childOptions.icon) {
iconClassName = childOptions.icon.options.className || '';
}
}
// Set the options and icon based on inherited child values
cluster.options.title = childMarkers.length + " x " + titleText;
return L.divIcon({
html: cluster.getChildCount(),
className: "big-icon " + iconClassName,
iconSize: [18, 18]
});
}
};
// Note: in case we want to load the sidebar items asynchronously, using this style of event
// handler will apply to both current and future items
$('#sidebar > ul').on('change', 'input', function () {
if (!(this.name in markers)) {
markers[this.name] = L.markerClusterGroup(markerClusterGroupOptions);
}
var groupMarker = markers[this.name];
if ($(this).is(':checked')) {
var markerOptions = {
icon: icons[stringToValue(this.name) % icons.length],
keyboard: false,
title: getExpandedName(this.name)
};
var targetLocations = locations[this.name].locations;
var newMarkers = targetLocations.map(target => {
var coords = map.unproject(target, 0);
return L.marker(coords, markerOptions);
});
groupMarker.addLayers(newMarkers);
map.addLayer(groupMarker);
} else {
map.removeLayer(groupMarker);
groupMarker.clearLayers(); // Get some memory back?
}
});
var sidebarList = new List("sidebar", { valueNames: ['itemName'] });
$('#selectAll').click(function() {
$('.list input:checkbox:not(:checked)').prop('checked', true).trigger('change');
});
$('#selectNone').click(function() {
$('.list input:checkbox:checked').prop('checked', false).trigger('change');
});
sidebarList.on('searchComplete', setSelectAllSafety);
sidebarList.on('filterComplete', setSelectAllSafety);
function setSelectAllSafety() {
$('#selectAll').prop('disabled', sidebarList.matchingItems.length > 1000);
}
});
// hash the string
function stringToValue(str) {
var hash = 0;
for (i = 0; i < str.length; i++) {
char = str.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash;
}
return Math.abs(hash);
};
function getExpandedName(internal_name) {
return ((locations[internal_name].display_name !== internal_name) ? locations[internal_name].display_name + ' — ': '') + internal_name;
}
function renderListItem(internal_name) {
var s = '<li><label><input type="checkbox" name="' + internal_name + '">';
if (locations[internal_name].display_name !== internal_name) {
s += '<span class="display-name">' + locations[internal_name].display_name + '</span> <span class="name-separator">—</span> ';
}
s += '<span class="internal-name">' + internal_name + '</span><span class="itemName">'+getExpandedName(internal_name)+'</span></label></li>';
return s;
};
</script>
</body>
</html>