开发者

Loading screen for Google Maps

I've noticed that Google Maps is taking longer than usual to load these days, and causes the browser to refresh many times before loading. Either way, this has led me to wonder how I can create a loading screen to display before the map fully loads.

Any suggestions?

Update: (In response to Gabi's code)

google.maps.event.addListener(map, 'tilesloaded', function(){
    document.getElementById('loading').innerHTML = '';
})

Is it possible to have a loading PN开发者_运维百科G overlay the entire map and remove it just before the tilesloaded event?


You can listen to the tilesloaded event:

google.maps.event.addListener(map, 'tilesloaded', function(){
    document.getElementById('loading').innerHTML = '';
})

Here is a working jsfiddle: http://jsfiddle.net/96WgM/2/


Alternatively, you could just set a loading gif image as the map div background:

http://jsfiddle.net/c962U/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜