Google 地图 js api v3:街景全景加载完毕?

发布于 2024-11-28 18:30:22 字数 235 浏览 3 评论 0原文

我的街景视图遇到了一些问题。我只想在街景加载完成后才显示街景,这样就不会显示灰色。我搜索了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

萌︼了一个春 2024-12-05 18:30:22

加载地图后隐藏并使 div 可见应该可以解决问题...

就像这样

<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>

希望它对您有帮助

hiding and making the div visible after map is loaded should do the trick ...

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

舞袖。长 2024-12-05 18:30:22

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

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

所以您可能确实想使用此事件!它也会在不同的上下文中启动,但是您可以通过一些标志变量来处理这个问题,该变量将在您单击按钮时设置,并在处理程序中进行测试,可能会超时。

所以,你应该做什么:

  1. 隐藏你的街景;但不要使用 display: none,使用技巧
    使用 jQuery UI 中的左偏隐藏技术 < 1.9(对于新
    版本 有它不起作用
    不幸的是

    <代码>.隐藏{
    位置:绝对!重要;
    左:-10000px!重要;
    }

    保持隐藏框架与最终结果的尺寸相同!

  2. 处理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:

  1. červen 2013 17:48:28.775 ===== CLICK OCCURRED ===== /nDwSC/2/show/ (line 210)
  2. červen 2013 17:48:28.780 resize /nDwSC/2/show/ (line 170)
  3. červen 2013 17:48:28.843 zoom_changed /nDwSC/2/show/ (line 173)
  4. červen 2013 17:48:29.603 pano_changed /nDwSC/2/show/ (line 158)
  5. červen 2013 17:48:29.622 position_changed /nDwSC/2/show/ (line 161)
  6. červen 2013 17:48:29.634 links changed

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
    :

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

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 map idle event (and idle event for google.maps.StreetViewPanorama doesn't exist). So the last resort is probably to use some fixed timeout - that works perfectly!

没企图 2024-12-05 18:30:22

如果你想在加载后加载全景图,为此你可以使用 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..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文