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