2012-01-20 16 views
4

地図上の特定の場所の通りパノラマを作ろうとしています。パノラマは、パノラマの位置としての位置でうまく動作することがありますが、それ以外のときは、コントロール付きの灰色の画面しか表示されません。これを解決するために、StreetViewService.getPanoramaByLocation()を使用しようとしています。この関数から返されるLatLngは、既に動作しているパノラマの位置のLatLngに非常に近いですが、この入力を位置として使用すると、パノラマは常にグレーです。私は多くの研究を行いましたが、まだ問題を解決することはできません。すべてのヘルプをいただければ幸いですGoogleマップStreetViewPanoramaの表示エラー

function init() { 
     var location = new google.maps.LatLng(<%=id%>); 
     map = new google.maps.Map(document.getElementById("map_canvas"), { 
      center: location, 
      zoom: 13, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     }); 
     marker = new google.maps.Marker({ 
      map: map, 
      position: location 
     }); 

     var client = new google.maps.StreetViewService(); 
     client.getPanoramaByLocation(location, 49, function(result, status) { 
      if (status == "OK") 
       location = result.location.latLng; 
     }); 
     myPano = new google.maps.StreetViewPanorama(document.getElementById("pano"), { 
      position: location, 
      pov: { 
       pitch: -10, 
       heading: 0, 
       zoom: 1 
      } 
     }); 
    } 

は、ここに私のコードです!ありがとう!

+0

google.maps.LatLng(Latitude、longitude)はLatLngオブジェクトを作成するための形式です。 –

答えて

5

これはあなたと少し違っています。ステータスが「ok」の場合は、StreetViewPanoramaを作成します。

var sv = new google.maps.StreetViewService(); 

sv.getPanoramaByLocation(streetViewLocation, 50, function(data, status) { 
    if (status == 'OK') { 
     //google has a streetview image for this location, so attach it to the streetview div 
     var panoramaOptions = { 
      pano: data.location.pano, 
      addressControl: false, 
      navigationControl: true, 
      navigationControlOptions: { 
       style: google.maps.NavigationControlStyle.SMALL 
      } 
     }; 
     var panorama = new google.maps.StreetViewPanorama(document.getElementById(strMapCanvasID), panoramaOptions); 
    } 
    else{ 
     //no google streetview image for this location, so hide the streetview div 
     $('#' + strMapCanvasID).parent().hide(); 
    } 
}); 
関連する問題