This is a snippet from the series described in Playing around with maps and streetview, and shows the calculation to convert between fov and zoom

Objective

The Streetmap image API uses field of view to figure out what part of a panorama to show, whereas streetview in Maps uses zoom levels. This is further complicated because 

  • The max streetview image API size is 640 x 640
  • The zoom levels for streetview are documented as 0-4, but in fact it can go as high as 5. However, in practise streetview stops zooming after about 3 with many panoramas
  • The conversion table given doesn’t appear to give a very accurate result.

Zoom levels are not whole numbers in streetview of course, so you need a conversion formulae. This  can derived from this table 

var fov = 180/ Math.pow (2 , zoom);

and 

var zoom = 1-Math.log(Math.tan(fov*Math.PI/360))/Math.log(2);

However, I find these formulae give a slight better (not quite perfect, but closer) representation

var fov = Math.atan(Math.pow(2,1-zoom))*360/Math.PI;

 

which give these results for zooms 0-4

127
90
53
28
14

The result

Using this formula, to calculate the fov from the zoom generates a pretty accurate set of parameters to pass over to the streetview image api as you can see from the examples below using various zoom levels with each of the APIs. A generated Streetview image API looks like this

The Streetview image API Maps Streetview selection
For more like this, see Ephemeral Exchange