Google 街景未显示在网站上

Google street view is not showing on a website

我正在尝试在网站上嵌入 Google 地图和街景。邮政编码、纬度和经度存储在数据库中,这些都可以,我的代码是:

<iframe width="600" height="450" frameborder="0" style="border:0"
                src="https://www.google.com/maps/embed/v1/place?q={{ $code[0] }}%20{{$code[1]}}&key=MYKEY" allowfullscreen></iframe>
                <hr />
                  <iframe src="https://maps.googleapis.com/maps/api/streetview?size=400x400&location={{ $pc[0]['latitude'] }},{{ $pc[0]['longtitude'] }}&fov=80&heading=70&pitch=0&key=MYKEY&signature=MYSIGNATURE" width="600" height="450" frameborder="0" style="border:0;" allowfullscreen=""></iframe>

PHP 返回此 OK 作为

 <iframe width="600" height="450" frameborder="0" style="border:0"
                src="https://www.google.com/maps/embed/v1/place?q=BA1%204HX&key=MYKEY" allowfullscreen></iframe>
                <hr />
                  <iframe src="https://maps.googleapis.com/maps/api/streetview?size=400x400&location=51.398734,-2.3936212&fov=80&heading=70&pitch=0&key=AMYKEY&signature=MYSIGNATURE" width="600" height="450" frameborder="0" style="border:0;" allowfullscreen=""></iframe>

问题是地图没问题,街景是一片空白。

我查看了 Google 的 Frefox 拒绝工具或任何东西,但什么也没有。

在尝试您的示例代码时,我遇到了 Refused to display .... in a frame because it set 'X-Frame-Options' to 'sameorigin' 错误:

请注意,街景静态 API 旨在嵌入 <img> 标签的 src 属性中,如下所示:

<img src="https://maps.googleapis.com/maps/api/streetview?size=400x400&location=51.398734,-2.3936212&fov=80&heading=70&pitch=0&key=YOUR_API_KEY&signature=SIGNATURE"/>

要解决此问题,您可以如上所述在 <img> 标记中加载街景静态图像,或者使用 Maps Embed API 的街景模式,它看起来像这样:

<iframe src="https://www.google.com/maps/embed/v1/streetview?location=51.398734,-2.3936212&fov=80&heading=70&pitch=0&key=YOUR_API_KEY" width="600" height="450" frameborder="0" style="border:0;" allowfullscreen=""></iframe>