-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.js
79 lines (64 loc) · 2.12 KB
/
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
function initStreetViewer(panoramaData) {
// console.log(globalPanoramaData);
// console.log(panoramaData.scenes["1"]["panorama"])
if(globalSelectedView != ""){
panoramaData.scenes["1"]["panorama"] = "Bsp_VR/"+panoramaData.locationName+"/" + globalSelectedView;
}
// console.log(panoramaData.file_list);
$('#views').children().remove().end();
panoramaData.file_list.forEach(function (item, index) {
// console.log(item, index);
// console.log(item);
$('#views').append($('<option>', {
value: item,
text: item
}));
});
if(globalSelectedView != ""){
$("#views").val(globalSelectedView);
}
let panorama = document.getElementById('panorama');
panorama.classList.remove('hide');
$("#views").show();
const panoramaViewer = pannellum.viewer('panorama', panoramaData);
let map = document.getElementById('map');
map.classList.add('hide');
let btn = document.getElementById('goBack')
btn.classList.remove('hide');
btn.addEventListener('click', () => {
panoramaViewer.destroy();
panorama.classList.add('hide');
map.classList.remove('hide');
btn.classList.add('hide');
$("#views").hide();
})
}
$('#views').on('change', function() {
globalSelectedView = this.value ;
initStreetViewer( globalPanoramaData );
});
async function mapSpotsToMap() {
const spotsData = await (await fetch('./spotsData.json')).json();
for (let spot of spotsData) {
let position = L.latLng([spot.y, spot.x]);
L.marker(position).addTo(map)
.bindPopup(spot.locationName)
.bindTooltip(spot.locationName)
.on('click', () => {
initStreetViewer(spot.panoramaData);
globalPanoramaData = spot.panoramaData;
})
}
}
//creates map
var map = L.map('map', {
crs: L.CRS.Simple,
minZoom: -1
});
var globalPanoramaData = "";
var globalSelectedView = "";
var bounds = [[0, 0], [1122, 3088]];
var image = L.imageOverlay('neomLine.jpg', bounds).addTo(map);
map.fitBounds(bounds);
////
mapSpotsToMap();