谷歌街景缩放到Fov [英] Google Street View zoom to Fov

查看:264
本文介绍了谷歌街景缩放到Fov的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要按照用户所选的方式(包括panoID,标题,音高和fov)保存街景视图图像。我有以下代码:

  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());
});

问题是我想将缩放比例保存为fov值



但它告诉我们,fov可以达到180,但是prev。链接告诉120值是最大值。为什么?
当然,我可以找到转换的比率,但也许存在正常的方式(即全景返回Fov而不是缩放)?

另外,似乎catch抓拍在pov_changed不是最好的方法。有时缩放无法正确更新

解决方案

发现以下功能可将缩放转换为FOV:

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

它的工作原理(几乎完全):)

ADDED



更确切的结果:

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

感谢trungk18 p>

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.com/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.com/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

解决方案

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

这篇关于谷歌街景缩放到Fov的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆