-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
102 lines (88 loc) · 2.62 KB
/
index.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
var panorama;
var panoramaData = {};
var panoramaList = Object.keys(panoramas);
function generatePanorama(pano, name) {
var links = pano.links.map(function(link) {
link = { pano: link[0], heading: link[1], description: link[2]};
if (panoramaData[link.pano] && panoramaData[link.pano].location) {
link.pano = panoramaData[link.pano].location.pano;
}
return link;
});
var tiles = pano.tiles || (pano.tiles = {});
tiles.centerHeading = pano.centerHeading;
tiles.getTileUrl = pano.getTileUrl || function() {
return pano.tileUrl ;
};
tiles.tileSize = tiles.tileSize
? new google.maps.Size(pano.tiles.tileSize[0], pano.tiles.tileSize[1])
: new google.maps.Size(3000, 1500);
tiles.worldSize = tiles.worldSize
? new google.maps.Size(pano.tiles.worldSize[0], pano.tiles.worldSize[1])
: new google.maps.Size(3000, 1500);
return {
location: {
pano: name,
description: pano.description,
// Apparently locations are not needed.
latLng: new google.maps.LatLng(locations[name])
},
links: links,
copyright: 'Imagery © 2016 VJC Makers’ Club',
tiles: tiles
};
}
function resetPOV() {
panorama.setPov({
heading: -100,
pitch: 5,
zoom: 0
});
}
function initPanoramas() {
panoramaList.forEach(function(key) {
var pano = panoramas[key];
if (pano) {
pano = generatePanorama(pano, key);
}
panoramaData[key] = pano || panoramaData[key];
});
}
function initStreetView() {
panorama = new google.maps.StreetViewPanorama(
document.getElementById('street-view'),
{
pano: panoramaData.outsideVJC.location.pano,
// Register a provider for our custom panorama.
panoProvider: function(pano) {
return panoramaData[pano];
}
}
);
resetPOV();
panorama.addListener('pano_changed', resetPOV);
// Add a link to our custom panorama from outside VJC.
panorama.addListener('links_changed', function() {
var currentPano = panorama.getPano();
var panoName = panoramaList.reduce(function(result, name) {
return result || (currentPano == panoramaData[name].location.pano && name);
}, undefined);
if (!panoramaData[panoName] || panoName == 'outsideVJC') {
panorama.getLinks().push(startingLink);
}
});
}
function start() {
// Use the Street View service to find a pano ID outside VJC.
var streetView = new google.maps.StreetViewService;
streetView.getPanorama(
{ location: locations.outsideVJC },
function(result, status) {
if (status == 'OK') {
panoramaData.outsideVJC = result;
initPanoramas();
initStreetView();
}
}
);
}