convertion between zoom and fov values

1,107 views
Skip to first unread message

JD Gauchat

unread,
Nov 4, 2011, 9:24:59 AM11/4/11
to google-map...@googlegroups.com
OK, this is the third time I post this message, no idea why is always deleted. I need help with the conversion of zoom values to fov values. A streetview returns the value of the zoom variable, but when I want to show that view as a static image I have to provide the value of the variable fov instead in the url. 
How can I convert the value of zoom to fov? Do I have to do it "manually"?

Thanks
JD

Hope this time the message is not deleted or someone give me an explanation about what I'm doing wrong here. 

geoco...@gmail.com

unread,
Nov 4, 2011, 9:32:21 AM11/4/11
to Google Maps JavaScript API v3

JD Gauchat

unread,
Nov 4, 2011, 9:44:05 AM11/4/11
to google-map...@googlegroups.com
Thanks Larry! Don't know why I didn't see it before! 

But, the answer doesn't solve my problem. In fact, that guy has exactly the same problem I have, he doesn't know how to convert the values and always keep the value of fov in 90.

So, if someone knows how to do it please let me know.

Thanks
JD

Keir

unread,
Nov 5, 2011, 1:37:39 PM11/5/11
to Google Maps JavaScript API v3
I didn't notice that when I created the wizard. I was planning to
improve it - but then I found someone had created a better one.

This one seems to have addressed the fov issue.

http://www.progettaremappeonline.it/blog/stviewgen/stvwimagen-en.html

Keir

JD Gauchat

unread,
Nov 5, 2011, 2:39:19 PM11/5/11
to google-map...@googlegroups.com

Hi Keir. Thanks! But the correct formula apparently is logarithmic (the formula of the example you showed is just multiplying by 16 the value of zoom, which is inaccurate). I couldn't figure out how to make it, so I came up with a list of predefined values I got comparing images and then just round the value of zoom to get only the 6 possibles integers. 

Here are the values I got:

zoom=0 ----> fov=120
zoom=1 ----> fov=90
zoom=2 ----> fov=53.5
zoom=3 ----> fov=28.3
zoom=4 ----> fov=14.3
zoom=5 ----> fov=10

So, when the zoom is 0, the fov value is 120, when the zoom is 2, the fov value has to be 53.5, and so on.
Since the zoom value is not always an integer, I rounded the number before to get the value of fov. Here is the code:

var values=[120, 90, 53.5, 28.3, 14.3, 10];
var zoom=panorama.getPov().zoom;
var fov=values[Math.round(zoom)];

I generated an array with the values of fov I got comparing images, then get the value of zoom from the streetview window and then rounded this value to get the right fov.

The result of this is more approximate than your example, but it will be better to have to proper math formula. If some one is better than me in mathematics and can figure it out, please share! :-)

Thank you all
JD

 

Barry Hunter

unread,
Nov 5, 2011, 4:01:07 PM11/5/11
to google-map...@googlegroups.com
var fov = 3.9018*Math.pow(zoom,2) - 42.432*zoom + 123;

Might be one possible formular.

I used Excel to make that. Plotted your values as a scatter graph.

Add a trendline for the graph (right click the line, and add Trendline)
In the options for the trendline, is an option to display the equation
to make the line.

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/N3jclP06TQkJ.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

JD Gauchat

unread,
Nov 5, 2011, 4:32:14 PM11/5/11
to google-map...@googlegroups.com
Thanks barry. Pretty close! I'm implementing that formula. The only thing is that the result goes over the limits. But that's not your formula's fault. That's because the limits for fov are 10 and 120, so there are no values for some zooms. For example, if the zoom is 0, the right value for fov should be more than 120, but that wouldn't be valid. So I just limit the results to min 10 and max 120 and that's it.

Thanks again.
JD

Thomas Orlita

unread,
Jun 7, 2017, 8:33:23 PM6/7/17
to Google Maps JavaScript API v3
If is anyone still interested, here are the formulas I use:

  • Convert fov to zoom:

    zoom = -(Math.log(fov/45)-2*Math.log(2))/Math.log(2)

  • Convert zoom to fov:

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


Reply all
Reply to author
Forward
0 new messages