Load container on page load
parent
4e76e12243
commit
10709b1342
45
script.js
45
script.js
|
@ -4,6 +4,18 @@
|
|||
var pano, newLoc;
|
||||
const main = document.getElementsByTagName('main')[0];
|
||||
|
||||
// Create panorama
|
||||
function init(){
|
||||
pano = new googlemaps.StreetViewPanorama(main, {
|
||||
panControl: false,
|
||||
zoomControl: false,
|
||||
addressControl: false,
|
||||
linksControl: false,
|
||||
motionTracking: false,
|
||||
motionTrackingControl: false
|
||||
});
|
||||
}
|
||||
|
||||
// Get street view imagery
|
||||
function getStreetViewData(loc,rad,cb) {
|
||||
// Ensure that the location hasn't changed (or this is the initial setting)
|
||||
|
@ -32,31 +44,24 @@ function getStreetViewData(loc,rad,cb) {
|
|||
}
|
||||
}
|
||||
|
||||
// Update street view image
|
||||
function updateStreetView(loc){
|
||||
|
||||
// Create panorama
|
||||
if ( typeof pano == 'undefined' ){
|
||||
$('main').empty();
|
||||
pano = new googlemaps.StreetViewPanorama(main, {
|
||||
panControl: false,
|
||||
zoomControl: false,
|
||||
addressControl: false,
|
||||
linksControl: false,
|
||||
motionTracking: false,
|
||||
motionTrackingControl: false
|
||||
// Wait for panorama
|
||||
if ( typeof pano != 'undefined' ){
|
||||
|
||||
// Set panorama
|
||||
getStreetViewData(loc, 2, function(data){
|
||||
pano.setPano(data.location.pano);
|
||||
pano.setPov({
|
||||
pitch: 0,
|
||||
// Point towards users's location from street
|
||||
heading: Math.atan((loc.lon-data.location.latLng.lng())/(loc.lat-data.location.latLng.lat()))*(180/Math.PI)
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Set panorama
|
||||
getStreetViewData(loc, 2, function(data){
|
||||
pano.setPano(data.location.pano);
|
||||
pano.setPov({
|
||||
pitch: 0,
|
||||
// Point towards users's location from street
|
||||
heading: Math.atan((loc.lon-data.location.latLng.lng())/(loc.lat-data.location.latLng.lat()))*(180/Math.PI)
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Track GPS location
|
||||
|
|
Loading…
Reference in New Issue