Retry after panorama loads

master
Keith Irwin 2017-08-07 11:50:05 -04:00
parent 7a40e7a6d1
commit 5ca77d4343
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
1 changed files with 9 additions and 5 deletions

View File

@ -2,11 +2,10 @@
/* global navigator google */
var pano, newLoc;
const main = document.getElementsByTagName('main')[0];
// Create panorama
function init(){
pano = new google.maps.StreetViewPanorama(main, {
pano = new google.maps.StreetViewPanorama(document.getElementsByTagName('main')[0], {
panControl: false,
zoomControl: false,
addressControl: false,
@ -47,9 +46,14 @@ function getStreetViewData(loc,rad,cb) {
// Update street view image
function updateStreetView(loc){
// Wait for panorama
if ( typeof pano != 'undefined' ){
// Panorama hasn't loaded
if ( typeof pano == 'undefined' ){
// Wait one second and try again
setTimeout(updateStreetView(loc),1000);
}
// Panorma has loaded
else {
// Set panorama
getStreetViewData(loc, 2, function(data){
pano.setPano(data.location.pano);