[英]Omitting Google Maps from .load() jquery function
I need the pages of a site to be fully loaded before showing, so I have used .load() jquery function to show an animated gif whilst loading. 在显示之前,我需要完全加载网站的页面,因此我在加载时使用了.load()jQuery函数来显示动画gif。 My problem is that Google maps is taking a while to load and so I need to omit it from the .load() function, but am not sure about how to do it.
我的问题是Google地图加载需要花费一些时间,因此我需要从.load()函数中忽略它,但不确定如何执行。 Any help would be appreciated.
任何帮助,将不胜感激。
<iframe src="This-is-the-google-maps-reference" width="100%" height="300" frameborder="0" style="border:0"></iframe>
<script src="js/jquery.js"></script>
<script type="text/javascript">
$(window).load(function() {
$(".loader").fadeOut("slow");
});
</script>
css: CSS:
loader {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background:url("http://smallenvelop.com/wp-content/uploads/2014/08/Preloader_21.gif") no-repeat center center rgba(255,256,255,1.0)
}
check both page load and map load to fire fadeout method. 检查页面加载和地图加载以触发淡出方法。 If page is loaded first, a flag is set.
如果首先加载页面,则会设置一个标志。 then this flag will be checked on map load.
然后将在地图加载时检查此标志。 if map is loaded first, vica versa.
如果首先加载地图,反之亦然。
var mapLoaded;
var pageLoaded;
$(window).load(function() {
if(mapLoaded)
$(".loader").fadeOut("slow");
else
pageLoaded = 1;
})
google.maps.event.addListenerOnce(map, 'idle', function(){
if(pageLoaded)
$(".loader").fadeOut("slow");
else
mapLoaded = 1;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.