Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

street view panorama completely grey

I have created a street view backbone view. The problem is that when shown, the panorama is completely grey. I am not sure if it has to do with the fact that it is inside a tab and the panorama is rendered when the tab is opened.

I am guessing that it might be an analogous problem that is fixed calling the resize event. Is there any similar thing that I could do?

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');
    }
});

EDIT:

I created a JSFiddle that replicates the problem: http://jsfiddle.net/kNS2L/3/

like image 986
AlexBrand Avatar asked Jun 16 '12 00:06

AlexBrand


1 Answers

Yeah, this is the old display:none with Maps and Panoramas. It works when I add setVisible(true):

  $('button').click(function() {
        $('#pano').show();
    panorama.setVisible(true);
    });
like image 175
Mano Marks Avatar answered Nov 12 '22 15:11

Mano Marks