Load container on page load
parent
4e76e12243
commit
10709b1342
29
script.js
29
script.js
|
@ -4,6 +4,18 @@
|
||||||
var pano, newLoc;
|
var pano, newLoc;
|
||||||
const main = document.getElementsByTagName('main')[0];
|
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
|
// Get street view imagery
|
||||||
function getStreetViewData(loc,rad,cb) {
|
function getStreetViewData(loc,rad,cb) {
|
||||||
// Ensure that the location hasn't changed (or this is the initial setting)
|
// Ensure that the location hasn't changed (or this is the initial setting)
|
||||||
|
@ -32,20 +44,11 @@ function getStreetViewData(loc,rad,cb) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update street view image
|
||||||
function updateStreetView(loc){
|
function updateStreetView(loc){
|
||||||
|
|
||||||
// Create panorama
|
// Wait for panorama
|
||||||
if ( typeof pano == 'undefined' ){
|
if ( typeof pano != 'undefined' ){
|
||||||
$('main').empty();
|
|
||||||
pano = new googlemaps.StreetViewPanorama(main, {
|
|
||||||
panControl: false,
|
|
||||||
zoomControl: false,
|
|
||||||
addressControl: false,
|
|
||||||
linksControl: false,
|
|
||||||
motionTracking: false,
|
|
||||||
motionTrackingControl: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set panorama
|
// Set panorama
|
||||||
getStreetViewData(loc, 2, function(data){
|
getStreetViewData(loc, 2, function(data){
|
||||||
|
@ -59,6 +62,8 @@ function updateStreetView(loc){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Track GPS location
|
// Track GPS location
|
||||||
if (!navigator.geolocation){ /* Show error */ }
|
if (!navigator.geolocation){ /* Show error */ }
|
||||||
else { navigator.geolocation.watchPosition(
|
else { navigator.geolocation.watchPosition(
|
||||||
|
|
Loading…
Reference in New Issue