在网站中嵌入谷歌照片领域

时间:2015-10-14 15:05:08

标签: google-maps google-maps-api-3 google-geocoder google-street-view photosphere

我正在使用代码在网站中嵌入谷歌地图街景照片。我从指南中获取代码:

function initialize() {
panorama = new google.maps.StreetViewPanorama(
  document.getElementById('street-view'),
  {
    position: {lat: myLat, lng: myLng},
    pov: {heading: 165, pitch: 0},
    zoom: 1
  });
}

代替myLat和myLng,我把照片网址中的纬度和经度放入。现在我发现所有类型照片的工作(街景照片,“看到里面的照片”)除了一个“照片球”,我发现有两种类型的照片球see here

现在,google最近更新谷歌地图,我认为“PHOTO SPHERE”是新的,而“Photo sphere”是最古老的,但如果我把第二个经度和经度放在一起,那么代码就可以了,新的一个它不起作用,我该怎么办?

示例:如果我使用此网址:http://www.google.com/maps/@0.5676777,37.527536,3a,75y,272.82h,93.02t/data=!3m5!1e1!3m3!1st4o4xj2l6HRAma2KT52brg!7i13312!8i6656,其中0.5676777为myLat,37.527536为myLng,则该照片将显示在网站中

如果我这样做:http://www.google.it/maps/@35.91208,14.498901,3a,89.9y,2.16h,87.34t/data=!3m8!1e1!3m6!1s-bkrM3HFU1vg%2FVhjysw39NSI%2FAAAAAAAAAPk%2F2PLOjiwhbh4!2e4!3e11!6s%2F%2Flh3.googleusercontent.com%2F-bkrM3HFU1vg%2FVhjysw39NSI%2FAAAAAAAAAPk%2F2PLOjiwhbh4%2Fw203-h101-n-k-no%2F!7i10000!8i5000

35.91208:myLat,14.498901:myLng

代码不起作用,不显示照片

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Street View</title>
    <style>
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      #street-view {
        height: 100%;
      }
    </style>
  </head>
  <body>
    <div id="street-view"></div>
    <script>
var panorama;
function initialize() {
  panorama = new google.maps.StreetViewPanorama(
      document.getElementById('street-view'),
      {
        position: {lat: 35.91208, lng: 14.498901},
        pov: {heading: 165, pitch: 0},
        zoom: 1
      });
}

    </script>
    <script async defer
         src="https://maps.googleapis.com/maps/api/js?signed_in=true&callback=initialize">
    </script>
  </body>
</html>

0 个答案:

没有答案