显示加载图像,同时加载谷歌地图 [英] show loading image while loading google map
问题描述
我正在使用Google Maps Javascript API在我的网站中使用aditional标记显示地图。这是触发器
var map = new google.maps.Map(document.getElementById(map_canvas),settings);
这可以正常工作,但地图需要几秒钟才能显示。
< div id =map_canvasstyle =width :700px; height:500px>< img src =/ image / ajax-loader.gif/>< / div>
但图像从不显示,只是直到地图显示的空白页面。
图像正在工作,因为如果我禁用地图加载功能,图像就在那里。
所以我认为谷歌地图在加载地图之前会清除div。
任何想法如何在等待时向用户显示加载反馈?我无法在API中找到函数...
您可能试图将地图div封装在另一个div中,将包含div的背景设置为具有某种动画图形。通常我发现在谷歌地图用作地图的元素内部操纵或放置任何东西并不是一个好主意。
I'm using Google Maps Javascript API for showing a map in my site with aditional markers. This is the trigger
var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
This works fine, but the map takes a few seconds to show. I'm putting a loading image in the map div like this:
<div id="map_canvas" style="width:700px; height:500px"><img src="/image/ajax-loader.gif" /></div>
But the image never shows, just the blank page until the map shows.
The image is working, because if I disable the map loading function, the image is there. So I think the google map clears the div before the map is loaded.
Any ideas how to show a loading feedback to the user while waiting? I could not find a function in the API...
You might try to wrap the map div inside another div, and set the containing div's background to have some sort of animation graphic. Generally I've found that it's not a good idea to manipulate or place anything inside the element that Google Maps uses as the map.
这篇关于显示加载图像,同时加载谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!