'정보보기'에 '파노라마보기'를 표시하려고합니다. 하지만 'Uncaught TypeError :'google.maps.geometry.spherical.computeHeading '을 사용하려고 할 때'정의되지 않은 'lat'속성을 읽을 수 없습니다."잡히지 않은 유형 오류 : 정의되지 않은 'lat'속성을 읽을 수 없습니다.
무엇이 잘못되었는지 확인할 수 있습니까?
var myMap;
var myMarkerList=[];
var myBound;
var myStreetView;
var radius;
var clickedMarker;
var m_mark;
var initMap = function(){
var myStyleType = new google.maps.StyledMapType(myStyles,{name: 'Styled Map'});
myMap = new google.maps.Map(document.getElementById('googleMap'), {
center:{lat:40.7413549, lng:-73.9980244},
zoom:13,
mapTypeControlOptions:{
mapTypeIds:['roadmap', 'satellite', 'hybrid', 'terrain',
'styled_map']
}
});
myMap.mapTypes.set('styled_map', myStyleType);
myMap.setMapTypeId('styled_map');
google.maps.event.addListener(myMap, 'click', function(event){
setMarkerList(event.latLng);
openInfoWindow(event.latLng);
});
myBound = new google.maps.LatLngBounds();
m_mark = new google.maps.Marker({
position:{lat: 40.7713024, lng: -73.9632393},
map:myMap,
title:'Park Ave Penthouse',
animation: google.maps.Animation.DROP,
});
m_mark.addListener('click', function(){
openStreetView(this);
clickedMarker = this;
});
myStreetView = new google.maps.StreetViewService();
radius = 50;
}
function setMarkerList(pos){
var myMarker = new google.maps.Marker({
position:pos,
map:myMap,
animation: google.maps.Animation.DROP,
});
myMarker.addListener('click', function(){
openStreetView(this);
clickedMarker = this;
});
myMarkerList.push(myMarker);
setBound(myMarker);
}
function openStreetView(targetMarker){
myStreetView.getPanoramaByLocation(targetMarker.position, radius, getParanomaView);
}
function getParanomaView(data, status){
var myInfo = new google.maps.InfoWindow();
if (status = google.maps.StreetViewStatus.OK) {
var nearStreetViewLocation = data.location.latlng;
var heading = google.maps.geometry.spherical.computeHeading(nearStreetViewLocation, clickedMarker.position);
myInfo.setContent('<div>'+clickedMarker.title+'</div><div id="panorama"></div>');
var panoramaOptions = {
position:nearStreetViewLocation,
pov: {
heading: heading,
pitch: 30
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('panorama'),panoramaOptions);
}
else{
myInfo.setContent('<div>'+clickedMarker.title+'</div><div>No Street View Found</div>');
}
myInfo.open(myMap, targetMarker);
}
저는이 문제를 일으킬 수있는 것에 관해서는 더 이상 성적인 것이 없으므로 도움을 크게 바랍니다.
이 오류는'comp.Heading' 라인 위의'console.log (nearStreetViewLocation);'console.log (clickedMarker.position); 행을 추가하면 항상 콘솔에 데이터를 보내 디버깅하는데 도움이됩니다. 실제로 어떤 데이터를 보내고 있는지 확인하십시오. 이러한 Google 객체 중 일부는 파악해야 할 곰입니다. (브라우저에서 F12 키를 누르면 dev 콘솔에서이 로그 라인을 볼 수 있습니다.) –
'if (status = google.maps.StreetViewStatus.OK)'에서 할당을 비교하지 않습니다. 나는 상태가 좋지 않다는 것을 의심한다. – James
당신은 오타가 있습니다 :'var nearStreetViewLocation = data.location.latlng;'는'var nearStreetViewLocation = data.location.latLng; '이어야합니다. 다른 주석/응답의 대부분은 유효하지만 그들은보고 된 것을 유발하지 않습니다 오류. – geocodezip