javascript – Google街景放大缩放至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值
https://developers.google.com/maps/documentation/streetview/intro(看看fov可选参数)
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.
我找到了一些“转换”信息
https://developers.google.com/maps/documentation/javascript/streetview#TilingPanoramas
但它告诉我,fov可以到180,但是上一个.链接告诉120值是最大值.为什么?
当然,我可以找到转换的比率,但也许存在正常的方式(即全景返回Fov而不是缩放)?
而且,似乎,捕捉放大pov_changed不是最好的方法.有时缩放不能正确更新
解决方法:
找到以下函数从zoom转换为FOV:
var k = Math.pow(0.5051, zoom);
var fov = 103.7587 * k;
它的工作原理(几乎完全):)
添加
更精确的结果:
var fov = 180 / Math.pow(2,zoom)
感谢trungk18
标签:javascript,google-maps,google-maps-api-3,google-street-view 来源: https://codeday.me/bug/20190528/1167714.html