source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Content/Web/GSVPano.js-master/build/GSVPano.min.js@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 1.6 KB
Line 
1var GSVPANO=GSVPANO||{};
2GSVPANO.PanoLoader=function(g){var g=g||{},d,k,m=new google.maps.StreetViewService,f=0,h=0,a=document.createElement("canvas"),i=a.getContext("2d");this.setProgress=function(b){if(this.onProgress)this.onProgress(b)};this.throwError=function(b){if(this.onError)this.onError(b);else console.error(b)};this.adaptTextureToZoom=function(){var b=416*Math.pow(2,d),c=416*Math.pow(2,d-1);a.width=b;a.height=c;i.translate(a.width,0);i.scale(-1,1)};this.composeFromTile=function(b,c,j){i.drawImage(j,512*b,512*c);
3f++;this.setProgress(Math.round(100*f/h));if(f===h&&(this.canvas=a,this.onPanoramaLoad))this.onPanoramaLoad()};this.composePanorama=function(){this.setProgress(0);console.log("Loading panorama for zoom "+d+"...");var b=Math.pow(2,d),c=Math.pow(2,d-1),j=this,l,a,e;f=0;h=b*c;for(e=0;e<c;e++)for(a=0;a<b;a++)l="http://maps.google.com/cbk?output=tile&panoid="+k+"&zoom="+d+"&x="+a+"&y="+e+"&"+Date.now(),function(b,c){var a=new Image;a.addEventListener("load",function(){j.composeFromTile(b,c,this)});a.crossOrigin=
4"";a.src=l}(a,e)};this.load=function(b){console.log("Load for",b);var c=this;m.getPanoramaByLocation(b,50,function(a,d){if(d===google.maps.StreetViewStatus.OK){if(c.onPanoramaData)c.onPanoramaData(a);google.maps.geometry.spherical.computeHeading(b,a.location.latLng);c.copyright=a.copyright;k=a.location.pano;c.location=b;c.composePanorama()}else{if(c.onNoPanoramaData)c.onNoPanoramaData(d);c.throwError("Could not retrieve panorama for the following reason: "+d)}})};this.setZoom=function(a){d=a;this.adaptTextureToZoom()};
5this.setZoom(g.zoom||1)};
Note: See TracBrowser for help on using the repository browser.