简体   繁体   English

谷歌地图js api v3:街景全景加载完成?

[英]Google maps js api v3: StreetView Panorama finished loading?

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我搜索了 api,但我认为没有任何事件可以利用: 文档

Is there any way (including non official ways) to show the streetview AFTER it's fully loaded?有没有办法(包括非官方方式)在街景满载后显示街景? Thanks!谢谢!

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:我做了一些测试(vinod_vh 的编辑示例,请参阅http://jsfiddle.net/nDwSC/2/ )并发现links_changed事件是最后一个启动的事件:

  1. červen 2013 17:48:28.775 ===== CLICK OCCURRED ===== /nDwSC/2/show/ (line 210) červen 2013 17:48:28.775 ===== 点击发生 ===== /nDwSC/2/show/(第 210 行)
  2. červen 2013 17:48:28.780 resize /nDwSC/2/show/ (line 170) červen 2013 17:48:28.780 调整 /nDwSC/2/show/ 大小(第 170 行)
  3. červen 2013 17:48:28.843 zoom_changed /nDwSC/2/show/ (line 173) červen 2013 17:48:28.843 zoom_changed /nDwSC/2/show/(第 173 行)
  4. červen 2013 17:48:29.603 pano_changed /nDwSC/2/show/ (line 158) červen 2013 17:48:29.603 pano_changed /nDwSC/2/show/(第 158 行)
  5. červen 2013 17:48:29.622 position_changed /nDwSC/2/show/ (line 161) červen 2013 17:48:29.622 position_changed /nDwSC/2/show/(第 161 行)
  6. červen 2013 17:48:29.634 links changed červen 2013 17:48:29.634 链接已更改

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:所以,你应该怎么做:

  1. hide your streetview;隐藏你的街景; but dont use display: none , use the trick with off-left hiding technique as in jQuery UI < 1.9 (for new versions there is it doesn't work unfortunately :但不要使用display: none ,使用左隐藏技术的技巧,如 jQuery UI < 1.9(对于新版本,不幸的是它不起作用

    .hide { position: absolute;important: left; -10000px !important; }

    keep the hidden frame of the same dimensions as the resultant one!保持与结果相同尺寸的隐藏框架!

  2. handle the links_changed event - remove the hide class, and do resize of the map.处理links_changed事件 - 移除hide class,并调整 map 的大小。

If you see that links_changed event is fired too early, there's no other possibility to do this cleanly by handling events.如果您看到links_changed事件被过早触发,则没有其他可能通过处理事件来干净地完成此操作。 You cannot even use the map idle event (and idle event for google.maps.StreetViewPanorama doesn't exist).您甚至不能使用 map idle事件(并且google.maps.StreetViewPanoramaidle事件不存在)。 So the last resort is probably to use some fixed timeout - that works perfectly!所以最后的手段可能是使用一些固定的超时 - 这非常有效!

hiding and making the div visible after map is loaded should do the trick...在加载 map 后隐藏并使 div 可见应该可以解决问题...

like this像这样

<div id="pano" style="position:absolute; left:410px; top: 8px; width: 400px; height: 300px;visibility:hidden;"></div>

<script> google.maps.event.addDomListener(window, 'load',initialize);
setTimeout('showPano()',1000);
function showPano(){
document.getElementById('pano').style.visibility='visible';}
</script>

hope it helped you希望对你有帮助

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) 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使用一些全局变量作为标志来了解准备好的 state..,注意:这是一个不稳定的想法,但适用于某些浏览器)

That will be easy way, in API, if you want to do that,这将是简单的方法,在 API 中,如果你想这样做,

refer event listeners,引用事件侦听器,

else别的

options have one option in documentation, options在文档中有一个选项,

ie IE

visible:: boolean:: If true, the Street View panorama is visible on load. visible:: boolean:: 如果为真,则街景全景图在加载时可见。

I hope this will make things easy on your side..我希望这会让你的事情变得容易..

I hope I have answered in context to your actual requirements..我希望我已经在上下文中回答了您的实际要求..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM