【问题标题】:showing street view using google api v3使用 google api v3 显示街景
【发布时间】:2014-08-22 12:54:42
【问题描述】:

我正在使用google api v3 显示街景,它在某个地方工作,但在某些地方没有显示街景示例(715 MORAGA ROAD,MORAGA),如果我们采取(950 COUNTRY CLUB DRIVE,MORAGA CA),它就可以工作94556)它在这里不起作用是我的代码:

        <!DOCTYPE html>
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <html>
            <head>
                <meta charset="utf-8">
                <title>Street View service</title>
                <style>
                  html, body, #map-canvas {
                    height: 100%;
                    margin: 0px;
                    padding: 0px
                  }
                </style>
            <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
            <script>
            var latitude=null;
            var longitude=null;
            var fenway;
            var map;
            var panoramaOptions;
            function initialize() {
             var value = '950 COUNTRY CLUB DRIVE , MORAGA CA 94556';
            alert("value"+value);
            var infoWindow = new google.maps.InfoWindow;
            $.ajax({
              url:"http://maps.googleapis.com/maps/api/geocode/json?address="+value+"&sensor=false",
              type: "POST",
              success:function(res){
            latitude=res.results[0].geometry.location.lat;
               alert("latitude"+latitude);
            longitude=res.results[0].geometry.location.lng;
            alert("longitude"+longitude);
             var fenway = new google.maps.LatLng(latitude, longitude);
              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);
              console.log(panoramaOptions);
              map.setStreetView(panorama);
            }});
            }
            google.maps.event.addDomListener(window, 'load', initialize);
            </script>
            </head>
            <body>
            <div id="map-canvas" style="width: 400px; height: 300px"></div>
            <div id="pano" style="position:absolute; left:410px; top: 8px; width: 400px; height: 300px;"></div>
            </body>
            </html>

【问题讨论】:

标签: javascript google-maps google-maps-api-3 map


【解决方案1】:

原因很简单:该位置没有可用的街景视图。

AFAIK 没有记录在案,但您可能会假设在距街景设置的位置 50 米 的距离内必须有可用的全景图。

950 COUNTRY CLUB DRIVE , MORAGA CA 94556(37.833037, -122.13019099999997) 的最近全景图 位于(37.833647, -122.12991799999998),偏移72 米

目前无法找到>50距离内最近的全景图,因此您可以检查50米内是否有全景图(请参阅https://developers.google.com/maps/documentation/javascript/streetview#StreetViewService),只有在全景图可用时才创建街景全景图.

另一种可能性(在 geocodezip 的示例中使用,这就是您在那里看到全景图的原因): 街景全景图通常放置在道路上(谷歌已通过汽车拍摄图像)。使用方向服务获取最近的道路(见Google Maps API - Getting Street Coordinates)并使用道路坐标作为街景的位置

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多