-
Notifications
You must be signed in to change notification settings - Fork 4
/
map_utils.js
63 lines (54 loc) · 2.24 KB
/
map_utils.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
function getPopupMedia(feature, list_id) {
var html = document.createElement('div');
if (feature.properties.image_id) {
var prefix = 'https://static.wikia.nocookie.net/gtawiki/images/';
var suffix = '.jpg';
if (list_id == "horseshoes"
|| list_id == "oysters") {
prefix = 'https://static.wikigta.org/en/images/';
suffix = '.JPG'
}
var image_link = document.createElement('a');
if (feature.properties.image_link) {
switch (list_id) {
case 'tags':
image_link.href = `https://gta.fandom.com/wiki/${feature.properties.image_link}`;
break;
case 'horseshoes':
case 'oysters':
image_link.href = `http://en.wikigta.org/wiki/${feature.properties.image_link}`;
break;
default:
image_link.href = prefix + feature.properties.image_id + suffix;
break;
}
} else {
image_link.href = prefix + feature.properties.image_id + suffix;
}
var image = document.createElement('img');
image.src = prefix + feature.properties.image_id + suffix;
image.className = 'popup-media';
image_link.appendChild(image);
html.appendChild(image_link);
} else if (feature.properties.video_id) {
var video = document.createElement('iframe');
video.className = 'popup-media';
// video.width = POPUP_WIDTH_16_9;
// video.height = POPUP_WIDTH_16_9 / 16 * 9;
video.src = `https://www.youtube-nocookie.com/embed/${feature.properties.video_id}`;
video.title = 'YouTube video player';
video.frameborder = 0;
// video.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; allowfullscreen'
html.appendChild(video);
}
return html;
}
// takes array of coords [x,y(,z)]
// returns L.latLng
function gtaCoordinatesToLeaflet(coords) {
// The gta map 0,0 is in the middle, 6000 square
// 192 (our map) / 6000 (gta map) = 0.032
lx = (coords[0] + 3000) * 0.032;
ly = (coords[1] - 3000) * 0.032;
return L.latLng(ly, lx);
}