2016-07-11 2 views
0

내 geolocation 응용 프로그램을 작동시키고 많은 검증 및 console.log() 함수를 수행 한 후에 모든 것이 작동해야합니다. 내 문제는 그것이 실제로 작동하지 않는다는 것입니다. 내가 원하는 Streetview 대신 회색 배경 만 있습니다.내 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'); 
     } 
    }); 

} 

은 내가 구글 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 호출은 beacause cross-domain 요청을받지 못했습니다.