保持Google地图v3地图隐藏,在需要时显示 [英] Keep a Google Maps v3 Map hidden, show when needed

查看:79
本文介绍了保持Google地图v3地图隐藏,在需要时显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法阻止Google Maps(JS,v3)地图从一开始就显示?我正在做一些预处理,并希望显示我的'正在加载'微调框,直到一切顺利(更加雄辩地说,隐藏地图 - 例如容器 div - 直到所有预处理完成 - 此时,显示地图)。

连接地图的空闲事件并没有多大帮助,因为当这个事件发生时地图已经显示点击。



我知道容器 div 在加载后被GMaps内联样式化,我的第一个想法是清除风格属性(同时监听空闲事件),但是看看是否有一种创建地图并在所有预处理完成之前不显示它的方式。

也许通过使用的参数new google.maps .Map 构造函数或 MapOption



对此有何看法?

预先感谢您! p>

  google.maps.event.trigger(map,'resize'); 

如果您已更改< div> display:none < div> 没有大小。


Is there a way of preventing a Google Maps (JS, v3) map being displayed from the get-go? I'm doing some pre-processing and would like to show my 'Loading' spinner until everything is good to go (more eloquently put, hide the map -- e.g. the container div – until all pre-processing is complete – at which point, show the map).

Hooking up the map's idle event doesn't help that much, since the map is already displayed when this event hits.

I know that the container div gets inline-styled by GMaps after loading, my first idea was to clear out the style attribute (whilst listening to the idle event), but it would be interesting to see if there is a way of creating the map and not displaying it until all pre-processing is done.

Maybe by using an argument to the new google.maps.Map constructor, or a MapOption ?

Any thoughts on this?

Thank you in advance!

解决方案

Also remember to call:

google.maps.event.trigger(map, 'resize');

if you have changed the size of the <div>. A display:none <div> has no size.

这篇关于保持Google地图v3地图隐藏,在需要时显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆