我有一个整页的谷歌地图,我希望能够将一些图像叠加在 map 上。到目前为止,我有以下代码:
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
#wrapper { position: relative; }
#over_map { position: absolute; background-color: transparent; top: 10px; left: 10px; z-index: 99; }
#over_map_right { position: absolute; background-color: transparent; top: 10px; right: 10px; z-index: 99; }
</style>
....
<body>
<div id="wrapper">
<div id="map_canvas" style="width:100%; height:100%"></div>
<div id="over_map">Left hand stuff goes here</div>
<div id="over_map_right">right hand stuff goes here</div>
</div>
</body>
这段代码对我来说似乎是正确的,但是当打开它时,我得到一个纯白的屏幕,只有
<div id="over_map">Left hand stuff goes here</div>
<div id="over_map_right">right hand stuff goes here</div>
显示。
还有其他方法吗?可以用 iframe 或类似的东西来完成吗?
迈克
最佳答案
问题是谷歌地图需要一个具体的 height
属性才能工作。
这是一个例子:http://jsfiddle.net/9qDhX/
请注意,height: 400px;
会起作用,但 height: 100%;
会留下空白屏幕。
获得“全屏” map 有多种解决方法。最好的跨浏览器将使用某种 jQuery 来根据当前窗口大小设置 map_canvas
的高度,并监听窗口调整大小以重置高度。
关于google-maps - 在谷歌地图上划分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14616909/