Skip to content
Advertisement

Google Street View Black Screen

I am trying to put a Google Streetview Panorama instance inside of a tab inside of an offcanvas element using Bootstrap 5.

If the default tab is the tab that contains the Streetview everything works fine as is demonstrated here:
https://codepen.io/taylormhicks90-the-bold/pen/OJxxqQN

If I use a different tab as the default tab the Streetview is initially black and doesn’t work unless you make it fullscreen first as is demonstrated here:
https://codepen.io/taylormhicks90-the-bold/pen/Yzrrgro

While I have a workaround of using the streetview tab as the default tab this in not the desired functionality. I have spent a few hours digging through googles docs and trying different workarounds. Just hopping someone can help explain why this is happening and what I can do to get it functioning properly or at least point me in the right direction.

I even tried this where I load the streetview while the streetview tab is the default tab and then change the tab to the pictures tab after the streetview has loaded, but it doesn’t work.
https://codepen.io/taylormhicks90-the-bold/pen/RwLLdeP

html:

JavaScript

Javascript:

JavaScript

Advertisement

Answer

Move StreetView call (new google.maps.StreetViewPanorama) into a function and then activate this function only when tab is active.

JavaScript

Only use this when default tab is not StreetView.

Reference: Bootstrap 5 tab events

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement