简体   繁体   English

等待页面呈现,直到加载Google Map

[英]Wait for rendering the page until the Google Map is loaded

My question is specific to Google maps v3 API. 我的问题特定于Google Maps v3 API。 I have a header (h3), an image, and Google Maps on my page. 我的页面上有标题(h3),图片和Google地图。 I want the page to wait until my Google Map loads entirely. 我希望页面等待直到我的Google Map完全加载。 Currently, the browser displays the h3 and image before Google Maps has completely loaded. 目前,浏览器会在Google地图完全加载之前显示h3和图像。

You might be able to use an event listener to see when the google map becomes idle. 您也许可以使用事件侦听器查看Google地图何时变为空闲状态。 Then once that event is fired you can add your other html through the JavaScript. 然后,一旦触发该事件,您就可以通过JavaScript添加其他html。

Here is a link to a similar question and answer: How can I check whether Google Maps is fully loaded? 以下是指向类似问答的链接: 如何检查Google Maps是否已满载?

The event you need is idle , as @Spazmoe06 told you, and you can use it like this : 正如@ Spazmoe06告诉您的那样,您需要的事件是idle ,您可以这样使用它:

google.maps.event.addListenerOnce(map, 'idle', function(){
    // ...
});

You can find a list of all Google Maps events here . 您可以在此处找到所有Google Maps事件的列表。

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

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