-
Notifications
You must be signed in to change notification settings - Fork 3
/
load_map.js
80 lines (67 loc) · 1.75 KB
/
load_map.js
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
var params = {},
pairs = document.URL.split('?')
.pop()
.split('&');
for (var i = 0, p; i < pairs.length; i++) {
p = pairs[i].split('=');
params[ p[0] ] = p[1];
}
if(!("map" in params)) {
window.location.replace("https://shiptest.net/maps");
}
var mapname = params["map"]
document.title = mapname;
var base = L.tileLayer("https://shiptest.net/renders/initial/padded/tiles/" + mapname + "/tiles/{z}/tile_{x}-{y}.png", {
minZoom: 1,
maxZoom: 6,
minNativeZoom: 3,
maxNativeZoom: 3,
continuousWorld: true,
tms: false
})
var areas = L.tileLayer("https://shiptest.net/renders/areas/padded/tiles/" + mapname + "/tiles/{z}/tile_{x}-{y}.png", {
minZoom: 1,
maxZoom: 6,
minNativeZoom: 3,
maxNativeZoom: 3,
continuousWorld: true,
tms: false
})
var pipenet = L.tileLayer("https://shiptest.net/renders/pipenet/padded/tiles/" + mapname + "/tiles/{z}/tile_{x}-{y}.png", {
minZoom: 1,
maxZoom: 6,
minNativeZoom: 3,
maxNativeZoom: 3,
continuousWorld: true,
tms: false
})
var powernet = L.tileLayer("https://shiptest.net/renders/powernet/padded/tiles/" + mapname + "/tiles/{z}/tile_{x}-{y}.png", {
minZoom: 1,
maxZoom: 6,
minNativeZoom: 3,
maxNativeZoom: 3,
continuousWorld: true,
tms: false
})
var map = L.map("mapbox", {
attributionControl: false,
minZoom: 1,
maxBounds: [
[64, -64],
[-1024, 1024]
],
maxBoundsViscosity: 1.0,
maxZoom: 6,
crs: L.CRS.Simple,
preferCanvas: true,
layers: [base]
}).setView([-64, 64], 3);
var baseMaps = {
"Ship": base,
"Areas": areas,
}
var overlayMaps = {
"Pipes": pipenet,
"Cables": powernet,
}
L.control.layers(baseMaps, overlayMaps).addTo(map)