-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_utils.js
31 lines (25 loc) · 1.36 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
function getPopupMedia(feature, list_id) {
var html = document.createElement('div');
const POPUP_WIDTH_16_9 = Math.min(500, window.screen.availWidth - 100, (window.screen.availHeight - 200) * 16 / 9);
const POPUP_WIDTH_4_3 = Math.min(500, window.screen.availWidth - 100, (window.screen.availHeight - 200) * 4 / 3);
if (feature.properties.image_id) {
var image_link = document.createElement('a');
image_link.href = `https://steamuserimages-a.akamaihd.net/ugc/${feature.properties.image_id}/`;
var image = document.createElement('img');
image.className = 'popup-media';
image.src = `https://steamuserimages-a.akamaihd.net/ugc/${feature.properties.image_id}/`;
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;
}