Google maps 嵌入的谷歌地图只是灰色的
我在我的页面上嵌入了谷歌地图。在IE8中,部分贴图渲染,但其余部分为灰色。在firefox中,整个地图都是灰色的。我的代码是:Google maps 嵌入的谷歌地图只是灰色的,google-maps,Google Maps,我在我的页面上嵌入了谷歌地图。在IE8中,部分贴图渲染,但其余部分为灰色。在firefox中,整个地图都是灰色的。我的代码是: <script type="text/javascript"> function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementByI
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
map.setUIToDefault();
}
}
window.setTimeout(function() {
initialize();
}, 750);
window.onunload = GUnload;
</script>
<div id='map_canvas' style="float:left; width:481px; height:450px; border-style:solid; border-width:2px; border-left:none; border-color:#5793C9">
函数初始化(){
if(GBrowserIsCompatible()){
var map=newgmap2(document.getElementById(“map_canvas”);
赛特中心地图(新格拉特林(37.4419,-122.1419),13);
map.setUIToDefault();
}
}
setTimeout(函数(){
初始化();
}, 750);
window.onunload=枪弹;
我从中复制的google示例代码使用了
和unload,但是我没有访问这些,因为我的主体是在母版页中定义的。我想这可能就是原因。我怎样才能修好它
编辑添加:my test.html也在做同样的事情。test.html的全部内容包括:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example: Simple Map</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=KEYABCDE"
type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
map.setUIToDefault();
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>
谷歌地图JavaScript API示例:简单地图
函数初始化(){
if(GBrowserIsCompatible()){
var map=newgmap2(document.getElementById(“map_canvas”);
赛特中心地图(新格拉特林(37.4419,-122.1419),13);
map.setUIToDefault();
}
}
750毫秒可能不足以让DOM完全加载
而不是:
window.setTimeout(function() {
initialize();
}, 750);
尝试使用:
window.onload = initialize;
750毫秒可能不足以让DOM完全加载 而不是:
window.setTimeout(function() {
initialize();
}, 750);
尝试使用:
window.onload = initialize;
确保默认值是合理的。您是否将地图置于现有点的中心?看起来你是。。。你是否给出了可接受的缩放级别?是否存在13的缩放级别?请确保您的默认值是合理的。您是否将地图置于现有点的中心?看起来你是。。。你是否给出了可接受的缩放级别?缩放级别是否为13?如果您在Firefox上遇到此问题,您可以为地图容器设置img CSS(层叠样式表),如下所示:
.gmap img {
max-width: none;
}
显然是“FF上的未记录功能”
我在这里找到了这个帖子:
我没有使用Drupal,但它解决了我在Firefox上的问题
问候
Kim如果您在Firefox上遇到此问题,您可以为地图容器设置img CSS(级联样式表),如下所示:
.gmap img {
max-width: none;
}
显然是“FF上的未记录功能”
我在这里找到了这个帖子:
我没有使用Drupal,但它解决了我在Firefox上的问题
问候
KimBTW,google api密钥设置正确吗?您的test.html工作正常。感谢您为我测试它。这必须是某种内部防火墙问题或其他问题(尽管主站点工作正常)。我现在已经切换到bing地图(更酷/更容易使用)。不知道该怎么处理这个问题?顺便说一句,google api密钥设置正确吗?你的test.html工作正常。谢谢你为我测试它。这必须是某种内部防火墙问题或其他问题(尽管主站点工作正常)。我现在已经切换到bing地图(更酷/更容易使用)。不知道该怎么处理这个问题?