I am using GStreetviewPanorama for one of my projects to show street view of a location. I want the values of parameters passed in GStreetviewPanorama method so that I can display the location exactly the way maps.google.com does (same camera orientation). I used :
latlngPoint is my GLatLng object here.
var panoramaOptions = { latlng: latlngPoint };
myPano = new GStreetviewPanorama(document.getElementById("strpano_div"), panoramaOptions);
I also tried
开发者_开发问答 myPano = new GStreetviewPanorama(document.getElementById("strpano_div"));
var myPOV = {yaw:270};
myPano.setLocationAndPOV(latlngPoint,myPOV);
When i passed the address corresponding to above latlng in maps.google.com, the location is shown at a different angle. Please suggest me the best values for GPov options like : yaw,pitch and zoom so that camera orientation is exactly same as used by maps.google.com.
Thank you.
I have altered this code from the original, but I am sure that you can follow:
var panoPosLat = panoPos.lat() / 180 * Math.PI;
var panoPosLng = panoPos.lng() / 180 * Math.PI;
var y = Math.sin(markerPosLng - panoPosLng) * Math.cos(markerPosLat);
var x = Math.cos(panoPosLat)*Math.sin(markerPosLat) - Math.sin(panoPosLat)*Math.cos(markerPosLat)*Math.cos(markerPosLng - panoPosLng);
brng = Math.atan2(y, x) / Math.PI * 195;
var pov = mybigpano2.getPov();
pov.heading = parseFloat(brng);
mybigpano2.setPov(pov);
I use 195 degrees because there are many streets that have many curves.
Changing the heading is the key.
I think this is where I found the code: enter link description here
I had some issues with originally and I posted here on stackoverflow: enter link description here
Hope that helps
精彩评论