最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Street View zoom to Fov - Stack Overflow

programmeradmin2浏览0评论

I need to save Street view image exactly as user selected (including panoID, heading, pitch and fov). I have the following code:

            panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'));
            panorama.addListener('pano_changed', function () {
                $('#panoID').val(panorama.getPano());
            });
            panorama.addListener('pov_changed', function () {
                $('#heading').val(panorama.getPov().heading);
                $('#pitch').val(panorama.getPov().pitch);
                $('#fov').val(panorama.getZoom());
            });

problem is I want to save zoom as fov value (look at fov optional parameter)

fov (default is 90) determines the horizontal field of view of the image. The field of view is expressed in degrees, with a maximum allowed value of 120. When dealing with a fixed-size viewport, as with a Street View image of a set size, field of view in essence represents zoom, with smaller numbers indicating a higher level of zoom.

I found some "convertation" information

but it tells, that fov can be till 180, but prev. link tells 120 value is maximum. Why? Of course, I can find ratio for convertation, but maybe exists normal way (i.e. panorama returns Fov instead of zoom)?

Also, seems, catch zoom in pov_changed is not the best way. Sometimes zoom is not updated properly

I need to save Street view image exactly as user selected (including panoID, heading, pitch and fov). I have the following code:

            panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'));
            panorama.addListener('pano_changed', function () {
                $('#panoID').val(panorama.getPano());
            });
            panorama.addListener('pov_changed', function () {
                $('#heading').val(panorama.getPov().heading);
                $('#pitch').val(panorama.getPov().pitch);
                $('#fov').val(panorama.getZoom());
            });

problem is I want to save zoom as fov value https://developers.google./maps/documentation/streetview/intro (look at fov optional parameter)

fov (default is 90) determines the horizontal field of view of the image. The field of view is expressed in degrees, with a maximum allowed value of 120. When dealing with a fixed-size viewport, as with a Street View image of a set size, field of view in essence represents zoom, with smaller numbers indicating a higher level of zoom.

I found some "convertation" information https://developers.google./maps/documentation/javascript/streetview#TilingPanoramas

but it tells, that fov can be till 180, but prev. link tells 120 value is maximum. Why? Of course, I can find ratio for convertation, but maybe exists normal way (i.e. panorama returns Fov instead of zoom)?

Also, seems, catch zoom in pov_changed is not the best way. Sometimes zoom is not updated properly

Share Improve this question asked Feb 10, 2016 at 22:27 Oleg ShOleg Sh 9,01120 gold badges105 silver badges179 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Found the following function to convert from zoom to FOV:

var k = Math.pow(0.5051, zoom);
var fov = 103.7587 * k;

it works (almost exactly) :)

ADDED

more precise results:

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

thanks to trungk18

You can use the following formula to convert fov to zoom:

  • fov to zoom:

    zoom = Math.log(180/fov)/(Math.log(2))

Or vice versa:

  • zoom to fov:

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

original answer

发布评论

评论列表(0)

  1. 暂无评论