http://docs.lucidinteractive.ca/index.php/Adding_A_Google_Map_to_your_site
width可以用%,height不行,估计是个bug.
有人写了函数调整大小,我大概试了一下,好像有问题,不过大致思路应该是对的。
function getWindowHeight()
{
if (window.self && self.innerHeight)
{
return self.innerHeight
}
if (document.documentElement && document.documentElement.clientHeight)
{
return document.documentElement.clientHeight;
}
return 0;
}
function resizeMap(mapId)
{
var offset = 0;
var map = document.getElementById(mapId);
for (var elem = map; elem != null; elem = elem.offsetParent)
{
offset += elem.offsetTop;
}
var windowHeight = getWindowHeight();
var height = windowHeight - offset - 10;
if (height >= 0)
{
map.style.height = height + "px";
}
}
width可以用%,height不行,估计是个bug.
有人写了函数调整大小,我大概试了一下,好像有问题,不过大致思路应该是对的。
function getWindowHeight()
{
if (window.self && self.innerHeight)
{
return self.innerHeight
}
if (document.documentElement && document.documentElement.clientHeight)
{
return document.documentElement.clientHeight;
}
return 0;
}
function resizeMap(mapId)
{
var offset = 0;
var map = document.getElementById(mapId);
for (var elem = map; elem != null; elem = elem.offsetParent)
{
offset += elem.offsetTop;
}
var windowHeight = getWindowHeight();
var height = windowHeight - offset - 10;
if (height >= 0)
{
map.style.height = height + "px";
}
}