Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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
Google maps 用于切换到街景的信息框按钮_Google Maps_Google Maps Api 3_Google Street View - Fatal编程技术网

Google maps 用于切换到街景的信息框按钮

Google maps 用于切换到街景的信息框按钮,google-maps,google-maps-api-3,google-street-view,Google Maps,Google Maps Api 3,Google Street View,我在信息框中有一个按钮。我要那个按钮切换到街景。按钮被触发并切换到街景,但我下面的代码将街景视为我的谷歌地图的一个完全独立的实体,这意味着我无法缩小到地图视图,并且街景级别上没有可见的标记: var fenway = new google.maps.LatLng(this.marker[id].position.jb,this.marker[id].position.kb); var panoramaOptions = { position: fenwa

我在信息框中有一个按钮。我要那个按钮切换到街景。按钮被触发并切换到街景,但我下面的代码将街景视为我的谷歌地图的一个完全独立的实体,这意味着我无法缩小到地图视图,并且街景级别上没有可见的标记:

        var fenway = new google.maps.LatLng(this.marker[id].position.jb,this.marker[id].position.kb);

    var panoramaOptions = {
        position: fenway,
        pov: {
            heading: 34,
            pitch: 10
        }
    };

    var panorama = new google.maps.StreetViewPanorama(document.getElementById("map-canvas"), panoramaOptions);
    this.gmap.setStreetView(panorama);
如何修改此选项,以便在当前地图中触发街景,而不是创建一个完全独立的实例?

这对我很有用:

    var streetViewMaxDistance = 100;          

    var point = new google.maps.LatLng(this.marker[id].position.jb,this.marker[id].position.kb);
    var streetViewService = new google.maps.StreetViewService();
    var panorama = this.gmap.getStreetView();

    streetViewService.getPanoramaByLocation(point, streetViewMaxDistance, function (streetViewPanoramaData, status) {

        if(status === google.maps.StreetViewStatus.OK){

            var oldPoint = point;
            point = streetViewPanoramaData.location.latLng;

            var heading = google.maps.geometry.spherical.computeHeading(point,oldPoint);            

            panorama.setPosition(point);
            panorama.setPov({
                heading: heading,
                zoom: 1,
                pitch: 0
            });
            panorama.setVisible(true);

        }else{
            // no street view available in this range, or some error occurred
            console.log("Sorry! Street View is not available.");
        }
    });
这对我很有用:

    var streetViewMaxDistance = 100;          

    var point = new google.maps.LatLng(this.marker[id].position.jb,this.marker[id].position.kb);
    var streetViewService = new google.maps.StreetViewService();
    var panorama = this.gmap.getStreetView();

    streetViewService.getPanoramaByLocation(point, streetViewMaxDistance, function (streetViewPanoramaData, status) {

        if(status === google.maps.StreetViewStatus.OK){

            var oldPoint = point;
            point = streetViewPanoramaData.location.latLng;

            var heading = google.maps.geometry.spherical.computeHeading(point,oldPoint);            

            panorama.setPosition(point);
            panorama.setPov({
                heading: heading,
                zoom: 1,
                pitch: 0
            });
            panorama.setVisible(true);

        }else{
            // no street view available in this range, or some error occurred
            console.log("Sorry! Street View is not available.");
        }
    });

希望这也会有用。要将其与我的现有地图集成,请执行以下操作:

map
是我的谷歌地图实例化类
map=new google.maps.map(el,mapOptions)

指针
是我的实例化标记:

    pointer = new google.maps.Marker({
        position: latLng,
        map: map
    });
latLng是:
latLng=new google.maps.latLng(lat,lng)

我所需要做的就是在所有其他东西下面添加以下代码,它监听对我的标记的单击,当它被单击时,它将街景设置为可见

    var panorama = map.getStreetView();
    panorama.setPosition(latLng);
    panorama.setPov({
        heading: 45,
        pitch:-10}
    );

    google.maps.event.addListener(pointer, 'click', function() {
        panorama.setVisible(true);
    });

希望这也会有用。要将其与我的现有地图集成,请执行以下操作:

map
是我的谷歌地图实例化类
map=new google.maps.map(el,mapOptions)

指针
是我的实例化标记:

    pointer = new google.maps.Marker({
        position: latLng,
        map: map
    });
latLng是:
latLng=new google.maps.latLng(lat,lng)

我所需要做的就是在所有其他东西下面添加以下代码,它监听对我的标记的单击,当它被单击时,它将街景设置为可见

    var panorama = map.getStreetView();
    panorama.setPosition(latLng);
    panorama.setPov({
        heading: 45,
        pitch:-10}
    );

    google.maps.event.addListener(pointer, 'click', function() {
        panorama.setVisible(true);
    });

对setStreetView方法参数使用null将嵌入式街景绑定到当前地图(用X完成以关闭街景并返回地图)

发件人:

将街景全景绑定到地图。此全景覆盖默认的街景全景,允许地图绑定到地图外部的外部全景。将全景设置为null会将默认嵌入的全景绑定回地图

this.gmap.setStreetView();
编辑:如果您有多个信息窗口,您可能需要使用如下功能,以便使用标记的位置更新街景:

function streetview(location) {

    location = location.replace('(', '').replace(')', '');
    var lat = location.split(',')[0];
    var lng = location.split(',')[1];
    var latlng = new google.maps.LatLng(lat, lng);
    this.gmap.setStreetView();
    this.gmap.getStreetView().setPosition(latlng);
}

对setStreetView方法参数使用null将嵌入式街景绑定到当前地图(用X完成以关闭街景并返回地图)

发件人:

将街景全景绑定到地图。此全景覆盖默认的街景全景,允许地图绑定到地图外部的外部全景。将全景设置为null会将默认嵌入的全景绑定回地图

this.gmap.setStreetView();
编辑:如果您有多个信息窗口,您可能需要使用如下功能,以便使用标记的位置更新街景:

function streetview(location) {

    location = location.replace('(', '').replace(')', '');
    var lat = location.split(',')[0];
    var lng = location.split(',')[1];
    var latlng = new google.maps.LatLng(lat, lng);
    this.gmap.setStreetView();
    this.gmap.getStreetView().setPosition(latlng);
}