Search code examples
javascriptgoogle-mapsgoogle-street-view

Setting streetview POV heading throws an error


In my application I have a Google map and the related Streetview in two different divs.
Streetview values of POV are stored inside the database, as a packed string, for example:
34.094522, -118.31127700000002,-141,0,1
The first two numbers are the lat and lang values, then I have heading, pitch and zoom.
Once the page is loaded, I set the POV inside the panorama in this way:

var pov = <field with saved values>.value.split(",");
PANORAMA.setPov({
    heading: (pov[2] ? pov[2].toInt() : 0),
    pitch: (pov[3] ? pov[3].toInt() : 0),
    zoom: (pov[4] ? pov[4].toInt() : 1)
});

This used to work fine until ~15 days ago, then I started to have the following error in Firebug:
Firebug error

After (several) tries, I tracked down the issue to the heading value: it works only if it's between -10 and 10 + (360 * < number of full rotations >), so -10/10, 350/370 and so on.
Looking at the docs, it should accept any values starting from 0; moreover, when I rotate the POV I update my location field getting the heading, pitch and zoom values:

var heading = PANORAMA.getPov().heading.toInt();
var pitch   = PANORAMA.getPov().pitch.toInt();
var zoom    = PANORAMA.getPov().zoom.toInt();

While executing the above code, I can see that the heading can get any value, indicating the number of degrees from the true north (as I expected to be).
Any ideas why I'm getting this error and why it only accepts values between -10 and 10?


Solution

  • There has been an API-update last week.

    I guess you are using the experimental version, at least the error occurs also with the demo used in the documentation(which also uses the experimental version): https://developers.google.com/maps/documentation/javascript/examples/streetview-simple

    There are several bugs in the new experimental version, this obviously is another bug.

    issue in the issue tracker

    Use the release-version instead(recommended in production) : https://maps.googleapis.com/maps/api/js?v=3