-
Notifications
You must be signed in to change notification settings - Fork 0
/
geocache.js
53 lines (37 loc) · 1.21 KB
/
geocache.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
const head = document.getElementsByTagName('head')[0];
const s = document.createElement('script');
s.textContent = `
L.Map.addInitHook(function () {
${common}
const iRef = setInterval(() => {
let removed = false;
this.eachLayer((layer) => {
if (layer !== freemapLayer && layer !== ortoLayer && layer._url) {
removed = true;
this.removeLayer(layer);
}
});
if (removed) {
clearInterval(iRef);
}
}, 200);
L.control
.layers(
{
'Freemap Outdoor': freemapLayer,
'Ortofotomozaika SR': ortoLayer,
}
)
.addTo(this);
freemapLayer.addTo(this);
const mapLinks = document.querySelector('#ctl00_ContentBody_MapLinks_MapLinks > ul');
const m = /lat=([\\d.]+)&lng=([\\d.]+)/.exec(mapLinks.firstChild.firstChild.href);
console.log(mapLinks.firstChild.firstChild.href, {m});
if (m) {
const li = document.createElement('li');
li.innerHTML = \`<a target="_blank" href="https://www.freemap.sk/?map=16/\${m[1]}/\${m[2]}&point=\${m[1]}/\${m[2]}">Freemap.sk</a>\`;
mapLinks.insertBefore(li, mapLinks.firstChild);
}
});
`;
head.insertBefore(s, head.firstChild);