2016-07-11 4 views
0

私はジオロケーションアプリケーションを動作させようとしており、多くの検証とconsole.log()関数の後、すべてがうまくいくはずです。私の問題は、実際には動作しないということです。私は欲しいストリートビューの代わりに灰色の背景だけを持っています。ここで私のstreetviewアプリケーション用の灰色の背景

コードです:

StreetView: function (latitude, longitude) { 
    $('#streetview').css({'width': $(window).width(), 'height': $(window).height()}); 

    var lookTo = {lat: parseFloat(latitude), lng: parseFloat(longitude)}; 
    var latlong = new google.maps.LatLng(parseFloat(latitude), parseFloat(longitude)); 
    var panoOptions = { 
     position: lookTo, 
     panControl: false, 
     addressControl: false, 
     linksControl: false, 
     zoomControlOptions: false 
    }; 
    // initialize a new panorama API object and point to the element with ID streetview as container 
    var pano = new google.maps.StreetViewPanorama(document.getElementById('streetview'), panoOptions); 
    // initialize a new streetviewService object 
    var service = new google.maps.StreetViewService; 
    // call the "getPanoramaByLocation" function of the Streetview Services to return the closest streetview position for the entered coordinates 
    console.log('Pano Positon :'+ pano.getPosition()); 
    service.getPanoramaByLocation(pano.getPosition(), 50, function (panoData) { 
     // if the function returned a result 
     if (panoData != null) { 
      // the GPS coordinates of the streetview camera position 
      var panoCenter = panoData.location.latLng; 
      console.log('PanoCenter' + panoCenter); 
      // the "computeHeading" function calculates the heading with the two GPS coordinates entered as parameters 
      var heading = google.maps.geometry.spherical.computeHeading(panoCenter, latlong); 
      console.log('Heading : '+ heading); 
      // now we know the heading (camera direction, elevation, zoom, etc) set this as parameters to the panorama object 
      var pov = pano.getPov(); 
      pov.heading = heading; 
      pano.setPov(pov); 
      // set a marker on the location we are looking at, to verify the calculations were correct 
      var marker = new google.maps.Marker({ 
       map: pano, 
       position: lookTo 
      }); 
     } else { 
      // no streetview found 
      console.log('not found'); 
     } 
    }); 

} 

私は、GoogleのAPIについて見つけるとコメントがあったコードの一部をコピーしました。だから、それは読みやすいはずです。 誰かがアイデアを持っている場合...

答えて

0

ズームパラメータを設定してみてください。これがうまくいかない場合は、このforumに記載されているように、バージョン3.20,3.21,3.22はもう使用できません。これをチェックしてくださいdocumentation。お使いのブラウザがInternet Explorerの場合は、supported versionを使用し、互換モードは使用しないでください。

これらの関連の質問をチェックしてください:

使用google.maps.StreetViewService.getPanoramaByLocation()所定の場所で利用可能なパノラマがあるかどうかを判断します。

この情報がお役に立てば幸い!

0

ありがとうございました。

実際、私は間違っていたことを発見しました。 Whitelist Pluginをインストールしていませんでした。

したがって、行:<access origin='*' />は解釈されませんでした。 $ .getScript経由でGoogle Apiスクリプトを入手した後、この関数(StreetView関数)を呼び出していました。 Ajax呼び出しは、クロスドメイン要求が受け入れられなかったために呼び出されませんでした。

関連する問題