简体   繁体   English

谷歌地图加载后隐藏加载图像

[英]hide loading image after google map load

I added a loading image to Google map api v3. 我在Google Map API v3中添加了加载图片。 On button click, the loading image shows up, but I am unable to hide the loading image after the map is loaded. 单击按钮后,将显示正在加载的图像,但是在加载地图后无法隐藏正在加载的图像。 Please help me with some tips. 请帮我一些提示。

Google map is present under div id: map_canvas Google地图显示在div ID下:map_canvas

Loading image is present under div id: inner 正在加载图片位于div ID:内部

I am using the code: $('div.inner').show(); 我正在使用代码:$('div.inner')。show(); to show the loading image after button click. 单击按钮后显示加载图像。

I tried this code to hide the loading image but it didn't work: 我尝试使用以下代码来隐藏加载图像,但是它不起作用:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(window).load(function(){
      $("#inner").hide();
})
</script>

I also tried using $(map_canvas).load(function()... 我也尝试使用$(map_canvas).load(function()...

and I also tried adding $("#inner").hide(); 而且我还尝试添加$(“#inner”)。hide(); in the last line of map code. 在地图代码的最后一行。 but nothing worked. 但没有任何效果。

Please help me hide the loading image after google map is loaded completely. 谷歌地图完全加载后,请帮助我隐藏加载图像。

Edit:........................................................................... 编辑:................................................ ...........................

I got it. 我知道了。

create a function like this: 创建一个像这样的函数:

function hide()
    {
        $('div.inner').hide();
    }

and call it in the last line of map code, it worked. 并在地图代码的最后一行中调用它,就可以了。

I don't use jQuery, so I'd do it like this: 我不使用jQuery,所以我会这样做:

var loadingDiv = document.getElementById('inner');
loadingDiv.style.display = 'none';

you can check out tilesloaded event in google map api v3. 您可以在Google Map API v3中检出tileloaded事件。 Check out SAMPLE PAGE 查看样本页面

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

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