Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a streetview included in my web site using google API to load it.

var theloc = new google.maps.LatLng(lat, lon);
var panoramaOptions = {
  addressControl: false,
  position: theloc,
  pov: {
    heading: 0, /* North */
    pitch: -40, /* Look down at angle 40deg */
    zoom: 0
  },
  visible: true
};
var streetview = new google.maps.StreetViewPanorama(document.getElementById("streetview"),
                     panoramaOptions);

This works, but I have one issue:

I am interested in loading the view by looking at the position I refer to, but when loading this it always points to north, and the location I specify is not necessarily in view.

If pointing to maps.google.com using URL to open a street view direclty in Google, I can simply omit the heading part of the panorama options parameter (cbp) like this:

'                                         \/ The heading value space                        '
https://maps.google.com/maps?layer=c&cbp=0,,,,40&cbll=58.9582956492561,5.62897047851361

This causes Google to automatically center the view on showing the position specified in cbll, and I don't need to know what heading to use.

Is it possible to do the same in the javascript API? If I try to omit the heading in the pov object, or initializing heading with null, the street view fails to load. I have also tried to set heading=-1, but that just points always to north. I also tried to not set the pov object at all, but that also always points to north (plus I don't get to set vertical angle 40 degrees down like I want).

share|improve this question
2  
Asked and answered on StackOverflow: stackoverflow.com/questions/7068365/… –  blah238 Jan 14 '13 at 8:31
add comment

1 Answer 1

up vote 2 down vote accepted

As commented by blah238 this was already answered on Stack Overflow in this question:

Getting the POV for Google StreetView API

So based on this answer, this is possible to do, although not as straight-forward as I hoped it would be...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.