OpenLayers-HTML DIV叠加层

问题描述:

我正在使用OpenLayers在标准HTML页面上显示地图,我想创建一个位于地图顶部的div.但是,div似乎总是被地图图块遮盖.

I'm using OpenLayers to display a map on a standard HTML page, and I want to create a div that sits on top of the map. However, the div always seems to be obscured by the map tiles.

我相信有一种向地图本身添加元素的方法,但是在这种情况下,这不是一个可行的选择,因为div可能会部分浮动在地图上,部分浮动在其他页面元素上.

I believe there is a way to add elements to the map itself, but in this case that isn't a viable option since the div will potentially float partially over the map, and partially over other page elements.

<div id="maphost" style="width: 100%; height: 100%" />
<div id="overlay" />

那是基本的HTML.我需要在两个DIV中添加哪些CSS值才能实现此目的?

That is the basic HTML. What CSS values do I need to add to either DIV to make this possible?

添加z-index

<div id="maphost" style="width:100%; height:100%; z-index: 0"></div>
<div id="overlay" style="z-index:9999"></div>