[英]How to update links dynamically in StreetView Panorama?
I'm using the Google Street View to display custom panorama's, and would like a way to dynamically update the links that is displayed in the view (rotating them, adding new ones, and deleting them) 我正在使用Google街景来显示自定义全景图,并想要一种动态更新视图中显示的链接的方法(旋转它们,添加新链接并删除它们)
When I say "links" I refer to the arrows you use to navigate inside street view. 当我说“链接”时,我指的是用于在街景中导航的箭头。
Now, I have an array that represents the links I want to add, and when I enter the panorama the first time, they get added properly (through the links_changed
event), however I have no way to see that the links have updated without jumping back and forth within streetview. 现在,我有一个数组代表我想要添加的链接,当我第一次进入全景时,它们被正确添加(通过links_changed
事件),但是我没有办法看到链接已更新而没有跳转在街景内来回走动。
I have tried "tricking" the panorama to think that it has changed with: 我试过“欺骗”全景,认为它已经改变了:
panorama.setPano(panorama.getPano());
I have also tried triggering the links_changed
event manually by issuing: 我还尝试通过发出以下links_changed
手动触发links_changed
事件:
google.maps.event.trigger(panorama, 'links_changed');
which runs the function just fine, but it doesnt do anything within streetview 它运行的功能很好,但它在streetview中没有做任何事情
Here's a JSFiddle that describes my problem: 这是一个描述我的问题的JSFiddle:
Try this: 尝试这个:
function createCustomLinks() {
var links = panorama.getLinks();
var panoId = panorama.getPano();
links.push({
heading: parseInt(degInput.value),
description: 'Something',
pano: panoId
});
panorama.setOptions({
links: links
});
}
And call createCustomLinks()
from your click event listener. 并从click事件侦听器调用createCustomLinks()
。 That should work. 这应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.