5

我创建了一个街景主干视图。问题是,当显示时,全景图是完全灰色的。我不确定它是否与它位于选项卡内并且在打开选项卡时呈现全景图有关。

我猜这可能是一个类似的问题,它已修复调用该resize事件。有没有我可以做的类似的事情?

App.DetailStreetView = Backbone.View.extend({
    initialize: function() {
        this.latLng = new google.maps.LatLng(37.869085,-122.254775);
    },
    render: function() {
        var sv = new google.maps.StreetViewService();
        this.panorama = new google.maps.StreetViewPanorama(this.el);
        sv.getPanoramaByLocation(this.latLng, 50, this.processSVData);        
    },
    processSVData: function(data, status) {
        if (status == google.maps.StreetViewStatus.OK) {
            // calculate correct heading for POV
            var heading = google.maps.geometry.spherical.computeHeading(data.location.latLng, this.latLng);
            this.panorama.setPano(data.location.pano);
            this.panorama.setPov({
                heading: 270,
                pitch:0,
                zoom:1, 
            });
        }
    },
    refresh: function() {
        this.panorama.setVisible(true);
        google.maps.event.trigger(this.panorama, 'resize');
    }
});

编辑:

我创建了一个复制问题的 JSFiddle:http: //jsfiddle.net/kNS2L/3/

4

1 回答 1

5

是的,这是旧display:none的地图和全景图。当我添加时它起作用setVisible(true)

  $('button').click(function() {
        $('#pano').show();
    panorama.setVisible(true);
    });
于 2012-06-16T01:12:29.930 回答