Google 地图 js api v3:街景全景加载完毕?
我的街景视图遇到了一些问题。我只想在街景加载完成后才显示街景,这样就不会显示灰色。我搜索了 api,但我认为没有任何可以利用的事件: 文档
有什么方法(包括非官方方法)可以在完全加载后显示街景吗?谢谢!
I'm having some trouble with my streetview. I want to show the streetview only after it finishes loading, so that the gray colour is not displayed. I searched the api, but I don't think there's any events that I can make use of: Documentation
Is there any way (including non official ways) to show the streetview AFTER it's fully loaded? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
加载地图后隐藏并使 div 可见应该可以解决问题...
就像这样
希望它对您有帮助
hiding and making the div visible after map is loaded should do the trick ...
like this
hope it helped you
我做了一些测试(编辑了 vinod_vh 的示例,请参阅 http://jsfiddle.net/nDwSC/2/) 并发现
links_changed
事件是最后一个启动的事件:所以您可能确实想使用此事件!它也会在不同的上下文中启动,但是您可以通过一些标志变量来处理这个问题,该变量将在您单击按钮时设置,并在处理程序中进行测试,可能会超时。
所以,你应该做什么:
隐藏你的街景;但不要使用
display: none
,使用技巧使用 jQuery UI 中的左偏隐藏技术 < 1.9(对于新
版本 有它不起作用
不幸的是:
<代码>.隐藏{
位置:绝对!重要;
左:-10000px!重要;
}
保持隐藏框架与最终结果的尺寸相同!
处理
links_changed
事件 - 删除hide
类,并调整地图大小。如果您发现
links_changed
事件触发得太早,则没有其他方法可以通过处理事件来干净地完成此操作。 您甚至无法使用地图idle
事件(并且idle<
google.maps.StreetViewPanorama
的 /code> 事件不存在)。所以最后的手段可能是使用一些固定的超时 - 这非常有效!I did some test (edited example of vinod_vh, see http://jsfiddle.net/nDwSC/2/) and found out, that the
links_changed
event is the last one launched:So you might actually want to use this event! It will be launched also in different contexts, but you can handle this by having some flag variable, which will be set when you click the button, and tested in the handler, with possible timeout.
So, what you should do:
hide your streetview; but dont use
display: none
, use the trickwith off-left hiding technique as in jQuery UI < 1.9 (for new
versions there is it doesn't work
unfortunately:
.hide {
position: absolute !important;
left: -10000px !important;
}
keep the hidden frame of the same dimensions as the resultant one!
handle the
links_changed
event - remove thehide
class, and do resize of the map.If you see that
links_changed
event is fired too early, there's no other possibility to do this cleanly by handling events. You cannot even use the mapidle
event (andidle
event forgoogle.maps.StreetViewPanorama
doesn't exist). So the last resort is probably to use some fixed timeout - that works perfectly!如果你想在加载后加载全景图,为此你可以使用 iframe 并且你可以使用 AJAX 加载器进行包装,在地图加载之前不会改变,(就绪状态==4),(或另一个 ajax 加载器包装使用一些全局变量作为标志来了解就绪状态..,注意:这是不稳定的想法,但适用于某些浏览器)
这将是简单的方法,在API中,如果你想这样做,
请参考事件侦听器,
否则
options 在文档中有一个选项,
即
visible :: boolean :: 如果为true,街景全景在加载时可见。
我希望这会让您的事情变得简单..
我希望我已经根据您的实际要求回答了..
If you want to load panorama after loaded, for that you may use iframe and with that you can have wrapper with AJAX loader, that will not change until the map loaded, (ready state ==4),( or one more ajax loader wrapper with some global variable as flag to know the ready state.., Note: this is unstable idea, but works with some browsers)
That will be easy way, in API, if you want to do that,
refer event listeners ,
else
options have one option in documentation,
i.e.
visible :: boolean :: If true, the Street View panorama is visible on load.
I hope this will make things easy on your side..
I hope I have answered in context to your actual requirements..