Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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 在网站上嵌入谷歌街景_Javascript_Google Maps - Fatal编程技术网

Javascript 在网站上嵌入谷歌街景

Javascript 在网站上嵌入谷歌街景,javascript,google-maps,Javascript,Google Maps,在我正在建立的网站上,我有一张谷歌地图作为联系方式的背景。它看起来不错,但我想把谷歌地图转换成谷歌街景,以获得一个漂亮的建筑图片,这样他们就知道他们要去哪里 我一直在尝试将我的代码转换为街景版本,但我似乎遗漏了一些东西,不太清楚是什么 如果您能提供一些帮助,我们将不胜感激。我以前从未做过街景地图 我目前拥有的代码如下所示 var mapOptions = { zoom: 20, center: map_center, ma

在我正在建立的网站上,我有一张谷歌地图作为联系方式的背景。它看起来不错,但我想把谷歌地图转换成谷歌街景,以获得一个漂亮的建筑图片,这样他们就知道他们要去哪里

我一直在尝试将我的代码转换为街景版本,但我似乎遗漏了一些东西,不太清楚是什么

如果您能提供一些帮助,我们将不胜感激。我以前从未做过街景地图

我目前拥有的代码如下所示

 var mapOptions = {
            zoom: 20,
            center: map_center,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            scrollwheel: false
        }

        var map = new google.maps.Map( document.getElementById( 'map-canvas' ), mapOptions ); 

        var beachMarker = new google.maps.Marker({
            position: new google.maps.LatLng(pos_a1, pos_b1), //my position I have stored as variables to make it cleaner
            map: map,
        });
我已经试过了

var mapOptions = {
            zoom: 1,
            center: map_center,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            scrollwheel: false
        }

        var map = new google.maps.StreetViewPanorama( document.getElementById( 'map-canvas' ), mapOptions ); 
        myPano.setVisible(true);

        var beachMarker = new google.maps.Marker({
            position: new google.maps.LatLng(pos_a1, pos_b1),
            map: map,
        });

但是地图消失了。

街景全景图需要一个
位置
-参数,而不是
中心

此外,您还使用了两个不同的变量(
map
和myPano)

这将起作用(当给定位置有全景可用时):

    var panoOptions = {
        position: map_center,
        scrollwheel: false
    }

    var myPano = new google.maps
                    .StreetViewPanorama( document.getElementById( 'map-canvas' ),
                                         panoOptions );