Google Maps - Street View Static Image

前端 未结 3 1488
时光取名叫无心
时光取名叫无心 2020-12-30 14:50

Is there a way to insert an address into a link and have it bring up the street view?

For instance:



        
相关标签:
3条回答
  • 2020-12-30 15:35

    Street View now has a static images API. Here's an example:

    http://maps.googleapis.com/maps/api/streetview?size=640x480&location=43.0635309,141.3253261&fov=120&heading=235&pitch=10&sensor=false
    

    Here's the docs:

    https://code.google.com/apis/maps/documentation/streetview/

    2011: マクド

    2017: マクドナルド

    0 讨论(0)
  • 2020-12-30 15:35

    You can embed whole the Street View on your page. Use googlemaps GStreetviewPanorama object for that. You can look at the example here:

    http://gmaps-samples.googlecode.com/svn/trunk/streetview/streetview_lazy.html

    0 讨论(0)
  • 2020-12-30 15:39

    Might be best to use Google Maps JavaScript API v3 to do it. See documentation and sample code at http://code.google.com/apis/maps/documentation/javascript/services.html#StreetView.

    Here's code from that page (with a few extraneous bits removed) that displays a street view:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Google Maps JavaScript API Example: Embedded StreetView</title>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>
    <script type="text/javascript">
    
      function initialize() {
        var bryantPark = new google.maps.LatLng(37.869260, -122.254811);
        var panoramaOptions = {
          position:bryantPark,
          pov: {
            heading: 165,
            pitch:0,
            zoom:1
          }
        };
        var myPano = new google.maps.StreetViewPanorama(document.getElementById("pano"), panoramaOptions);
        myPano.setVisible(true);
      }
    </script>
    </head>
    <body onload="initialize()">
      <div id="pano" style="width: 425px; height: 240px"></div>
    </body>
    </html>
    

    Note that the code uses latitude and longitude rather than address. If all you have is a street address, you can use Google's Geocoder object to convert an address to a LatLng object.

    0 讨论(0)
提交回复
热议问题