Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple.html does not work by Cross-Origin error #21

Open
mrksy opened this issue Jul 2, 2014 · 7 comments
Open

simple.html does not work by Cross-Origin error #21

mrksy opened this issue Jul 2, 2014 · 7 comments

Comments

@mrksy
Copy link

mrksy commented Jul 2, 2014

Hi.

I tried viewer.html, and it was working fine.
But simple.html did not work properly in the following errors.

Does anyone know how to fix this error?

Image from origin 'http://maps.google.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. simple.html:1
GET http://maps.google.com/cbk?output=tile&panoid=v_n6NqVhurgAAAQWh5FkkQ&zoom=1&x=0&y=0&1404267653455 400 (Bad Request) GSVPano.js:90
Image from origin 'http://maps.google.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. simple.html:1
GET http://maps.google.com/cbk?output=tile&panoid=v_n6NqVhurgAAAQWh5FkkQ&zoom=1&x=1&y=0&1404267653455 400 (Bad Request) GSVPano.js:90

@jordirosa-p5
Copy link

Hi,
the same issue here, simple.html doesn't work properly, it seems to correctly pre-load some images (like http://maps.google.com/cbk?output=tile&panoid=vj2sSEmT10zdVm65O74LFw&zoom=1&x=0&y=0&1405079779396) but then it throws a 400 (Bad Request) error when trying to get the two other images mrksy states.

@Jip-Hop
Copy link

Jip-Hop commented Aug 29, 2014

I have the same issue with simple.html. Also, when I change travel mode to from DRIVING to WALKING in the viewer.html, I get the Cross-Origin error when using roads that are not available to cars.

@mrksy
Copy link
Author

mrksy commented Sep 11, 2014

@Jip-Hop
I was changed to DirectionsTravelMode.WALKING from DRIVING. it works fine!
Thanks!

@devasur
Copy link

devasur commented Sep 20, 2014

A slight modification to GSVPano.js (method : this.composePanorama) will make these errors go away. Some of the tiles requested are boundary ones which does not exists. You can ignore these errors and still Pano will load just fine. Here I am watching for error on tile request and onError just returning an empty image.

this.composePanorama = function (panoId) {

    this.setProgress(0);
    console.log('Loading panorama for zoom ' + _zoom + '...');

    var w = (_zoom==3) ? 7 : Math.pow(2, _zoom),
        h = Math.pow(2, _zoom - 1),
        self = this,
        url,
        x,
        y;

    _count = 0;
    _total = w * h;

    for( y = 0; y < h; y++) {
        for( x = 0; x < w; x++) {
            url = 'https://maps.google.com/cbk?output=tile&panoid=' + panoId + '&zoom=' + _zoom + '&x=' + x + '&y=' + y + '&' + Date.now();
            (function (x, y) { 
                var img = new Image();
                img.addEventListener('load', function () {
                    self.composeFromTile(x, y, this);
                });
                img.addEventListener('error', function () {
                    self.composeFromTile(x, y, new Image());
                });
                img.crossOrigin = 'anonymous';
                img.src = url;
            })(x, y);
        }
    }

};

@yangfei19881024
Copy link

同样遇到此问题,不知如何解决

@TStrothjohann
Copy link

Thanks @devasur

@ruxandrafed
Copy link

Thanks @devasur! That totally fixed it! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants