Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么StreetView JS API不能正确镜像StreetView静态API?_Javascript_Google Maps Api 3_Google Static Maps_Google Street View - Fatal编程技术网

Javascript 为什么StreetView JS API不能正确镜像StreetView静态API?

Javascript 为什么StreetView JS API不能正确镜像StreetView静态API?,javascript,google-maps-api-3,google-static-maps,google-street-view,Javascript,Google Maps Api 3,Google Static Maps,Google Street View,我试图使用JS StreetView API让用户选择一个他们希望用于静态街景图像的视图。我已经建立了一个基本的测试,位于我的实例和下面,供未来的子孙后代使用 第一次加载页面时,将加载StreetView视图端口,并正确加载反映该视图端口的静态图像。如果我在不离开位置的情况下四处平移,静态图像将正确更新 我使用对pov_changed、position_changed和visible_changed事件的调用来调用静态图像的更新。我在触发这些事件之间放置了半秒的延迟,以避免调用配额错误 我的问题

我试图使用JS StreetView API让用户选择一个他们希望用于静态街景图像的视图。我已经建立了一个基本的测试,位于我的实例和下面,供未来的子孙后代使用

第一次加载页面时,将加载StreetView视图端口,并正确加载反映该视图端口的静态图像。如果我在不离开位置的情况下四处平移,静态图像将正确更新

我使用对pov_changed、position_changed和visible_changed事件的调用来调用静态图像的更新。我在触发这些事件之间放置了半秒的延迟,以避免调用配额错误

我的问题是: 如果我使用任何“clickToGo”操作来更改我的位置,则静态街景中显示的位置纬度/经度不能正确反映JS街景端口。从我所看到的,pov fov/zoom、航向、俯仰都是正确的,但我的位置不正确

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script type="text/javascript">

          function initialize() {
            var panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"), {
              position: new google.maps.LatLng(42.345573,-71.098326),
              pov: {
                heading: 34,
                pitch: 10,
                zoom: 1
              }
            });

            /**
             * Build static URL from streetview JS instance settings
             */
            function getStaticUrl(secure) {
                secure = (secure) ? 's' : '';
                var latlng = panorama.getPosition();
                var pov = panorama.getPov();
                var url = "http" + secure + "://maps.googleapis.com/maps/api/streetview?size=500x400&location=" + encodeURIComponent(latlng.lat() + ", " + latlng.lng()) + "&fov=" + (180 / Math.pow(2, pov.zoom)) + "&heading=" + encodeURI(pov.heading) + "&pitch=" + encodeURI(pov.pitch) + "&sensor=false";
                console.log("lat: " + latlng.lat() + "     " + "lng: " + latlng.lng());
                console.log("img src: " + url);
                return url;
            }

            /**
             * To stop overusing quota errors with the static streetview API, wait half a second after streetview has stopped moving to
             * update image preview.
             */
            var _updateStreetViewWait = 0;
            var _handleStreetViewPovChange = function() {
                clearTimeout(_updateStreetViewWait);
                _updateStreetViewWait = setTimeout(function() {
                    var linkUrl = getStaticUrl();
                    $('#link').html("<a target='_blank' href='" + linkUrl + "'><img src='" + linkUrl + "'/></a>");
                }, 500);
            };
            google.maps.event.addListener(panorama, 'pov_changed', _handleStreetViewPovChange);
            google.maps.event.addListener(panorama, 'position_changed', _handleStreetViewPovChange);
            google.maps.event.addListener(panorama, 'visible_changed', _handleStreetViewPovChange);
          }
        </script>
    </head>
    <body onload="initialize()">
      <div id="pano" style="width: 500px; height: 400px"></div>
      <div id="link" style="width:100%; height: 2%"></div>
    </body>
</html>

这两种不同的API使用不同的投影系统。JS API根据浏览器的不同使用不同的投影,因此它们不会对齐

这两个不同的API使用不同的投影系统。JS API根据浏览器的不同使用不同的投影,因此它们不会为了解决我的问题而排成一行

,将问题标记为“非建设性”的人能否告诉我如何将我的问题重新表述为适当的问题?这两个不同的API使用不同的投影系统。JSAPI根据浏览器的不同使用不同的投影,所以它们不会对齐。该死,我也这么想,但我觉得我已经把问题摆出来了。因为那是正确的答案,如果你把它作为一个答案,我会把它标对的。看起来我没有被咬过。为了解决我的问题,将问题标记为“非建设性”的人能否告诉我如何将问题重新表述为适当的问题?两个不同的API使用不同的投影系统。JSAPI根据浏览器的不同使用不同的投影,所以它们不会对齐。该死,我也这么想,但我觉得我已经把问题摆出来了。因为那是正确的答案,如果你把它作为一个答案,我会把它标对的。反正我也没被咬过。