Google街景位置未正确更改

时间:2014-03-19 22:56:48

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

以下是我正在处理的内容的链接(代码也包含在最后):http://urloritdidnthappen.appspot.com/1557001

这是我制作的jsFiddle的链接,它有相同的错误(代码略有不同,但问题是相同的): http://jsfiddle.net/stealthiskarl/sNfd2/1/

它应该做的是如果你点击不同的房间,它会带你到不同的房间。但是,当我改变建筑物内街景的纬度和经度时,它什么都不做。它总是把我带到建筑物内的同一个地方。

如果您注意到,起始纬度/经度为:

LatLng(40.75506,-73.999696)

然后当你点击右上角的房间时,lat和lng是:

LatLng(40.755043,-73.999653)

所以它应该把你带到一个不同的地方......但事实并非如此!但是,当您单击左下方的房间时(出于测试目的,它会将您发送到建筑物外),它会将您发送到:

LatLng(40.754802,-73.999657)

正常工作。有没有办法解决这个问题,所以我的lat / lng值在建筑物内部实际上有效?如果它有帮助,here is a link到我正在使用的街景视图上的位置。

由于

以下是我正在使用的代码:

<!DOCTYPE HTML>
<html>
<head>
    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDOXB3qYYiL7NpxucBIEDq9CX5DlyiL5Ns&sensor=false"></script>

</head>

<body>
    <script>
        var map;

        function initialize() {
            var fenway = new google.maps.LatLng(40.75506, -73.999696);
            var panoramaOptions = {
                position: fenway,
                pov: {
                    heading: 263,
                    pitch: 10
                }
            };
            var panorama = new google.maps.StreetViewPanorama(document.getElementById('map-canvas'), panoramaOptions);
            var mapOptions = {
                center: fenway,
                zoom: 14,
                streetView: panoramaOptions
            };
            map = new google.maps.Map(
                document.getElementById('map-canvas'), mapOptions);
        }

        function moveToRoom(roomNumber) {
            var fenway;
            if (roomNumber == 1)
                fenway = new google.maps.LatLng(40.755043, -73.999653);
            else
                fenway = new google.maps.LatLng(40.754802, -73.999657);
            var panoramaOptions = {
                position: fenway,
                pov: {
                    heading: 263,
                    pitch: 10
                }
            };
            var panorama = new google.maps.StreetViewPanorama(document.getElementById('map-canvas'), panoramaOptions);
            map.setStreetView(panorama);

        }

        google.maps.event.addDomListener(window, 'load', initialize);
    </script>

    <div style="position:relative;width=454px; height=206px">
        <img src="http://location05.com/images/floorplan_preview.jpg" alt="floorplan" style="position: absolute; z-index:-1;" />
        <div style="absolute; z-index:0; padding-top:8px; padding-left:285px;">
            <img src="http://location05.com/images/sample_floorplan_overlay.png" alt="floorplan" style="opacity:0;filter:alpha(opacity=0)" 
            onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" 
            onmouseout="this.style.opacity=0;this.filters.alpha.opacity=0"
            onclick="moveToRoom(1);" />
        </div>
        <div style="absolute; z-index:0; padding-top:59px; padding-left:31px;">
            <img src="http://location05.com/images/sample_floorplan_overlay.png" alt="floorplan" style="opacity:0;filter:alpha(opacity=0)" 
            onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" 
            onmouseout="this.style.opacity=0;this.filters.alpha.opacity=0"
            onclick="moveToRoom(2);" />
        </div>

    </div>

    <div id="map-canvas" style="width: 562px; height: 314px"></div>
</body>
</html>

0 个答案:

没有答案