在Google API上使用LatLng获取街景图像

时间:2015-07-26 03:07:56

标签: javascript google-maps google-maps-api-3 google-street-view

我想从谷歌街景中获取带有LatLng信息的图片。

https://developers.google.com/maps/documentation/javascript/

我在Google服务的文档中阅读了几乎所有内容,但我找不到我想要的选项。

还有什么我会把一件事作为参考吗?

1 个答案:

答案 0 :(得分:2)

这里有一对来自Google sample1的好例子 和sample2 Whit建立一个合适的网页并包含所有相关信息并不是一件好事,这并不困难

sample2的代码

  <!DOCTYPE html>
  <html>
    <head>
      <meta charset="utf-8">
      <title>Street View service</title>
      <style>
        html, body, #map-canvas {
          height: 100%;
          margin: 0;
          padding: 0;
        }

      </style>
      <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
      <script>
  function initialize() {
    var fenway = new google.maps.LatLng(42.345573, -71.098326);
    var mapOptions = {
      center: fenway,
      zoom: 14
    };
    var map = new google.maps.Map(
        document.getElementById('map-canvas'), mapOptions);
    var panoramaOptions = {
      position: fenway,
      pov: {
        heading: 34,
        pitch: 10
      }
    };
    var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'), panoramaOptions);
    map.setStreetView(panorama);
  }

  google.maps.event.addDomListener(window, 'load', initialize);

      </script>
    </head>
    <body>
      <div id="map-canvas" style="width: 45%; height: 100%;float:left"></div>
      <div id="pano" style="width: 45%; height: 100%;float:left"></div>
    </body>
  </html>

或最简单的嵌入式访问https://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,-73.988354&fov=90&heading=235&pitch=10

所有来自谷歌。