I am trying to take a street panorama of a specific location on a map. Sometimes a panorama works fine with the location as the position of the panorama, while in other cases only a gray screen with controls is displayed. To solve this problem, I am trying to use StreetViewService.getPanoramaByLocation (). The returned LatLng from this function is VERY close to the LatLng of the panorama locations that are already working, but the panorama is ALWAYS gray when I use this input as a position. I have done a lot of research and still can not solve the problem.
Here is my code:
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 } }); }
Any help would be greatly appreciated! Thanks!
source share