简体   繁体   English

堆叠div和openlayers矢量层

[英]Stacking divs and openlayers vector layers

I have an openlayers map, and a div which contains some information about elements that have been moused over on the map. 我有一个openlayers地图,还有一个div,其中包含一些有关在地图上被鼠标悬停的元素的信息。 The openlayers events trigger showing or hiding the div, but the div is not a part of the open layers map. openlayers事件触发显示或隐藏div,但div不是开放层地图的一部分。

The problem that I am having is that the map layers stack in front of the div. 我遇到的问题是地图图层堆叠在div的前面。 I would prefer that they stack behind the div. 我希望它们堆叠在div后面。 I don't fully understand how openlayers stacking works, and there's no explanation in the documentation that I have found which explains stacking in the context of DOM elements that are not a part of the map. 我不完全了解openlayers堆栈的工作原理,并且在我发现的文档中没有任何说明,该说明在不属于地图的DOM元素的上下文中解释了堆栈。

Can anyone help me here? 有人能帮我一下吗? CSS and HTML follows. 随后是CSS和HTML。 Openlayers exists on the map-id div. Openlayers存在于map-id div上。

HTML: HTML:

<div id="combat-contentBox">
     <div id="map-id"></div>
     <div id="ship-info" class="ui-widget hidden"></div>
     <div id="tileproperties"></div>
</div>

CSS: CSS:

#map-id {
    width: 761px; 
    height: 598px;
    float:left;
    margin:0;
    background-image:url('../../map/selfgraphics/background3.jpg');
    z-index: -25;
}

#ship-info {
    align: center;
    position: absolute;
    width: auto;
    bottom: 5px;
    z-index: 500;
    text-align: center;
    background: #000000 url(../../library/externallibraries/jqueryui/css/dark-hive/images/ui-bg_dots-small_25_000000_2x2.png) 50% 50% repeat;
    color: #ffffff;
    border: solid grey 1px;
    padding: 5px;
}

Like I said above, the openlayers vector layers from the map-id div stack over the ship-info div, but I am pretty sure that the map-id div itself is stacking behind the ship-info div, because the map-id background is stacking behind the ship-info div. 就像我上面说的,openlayers从map-id div堆栈中的向量层覆盖在ship-info div上,但是我很确定map-id div本身堆叠在ship-info div的后面,因为map-id背景堆叠在ship-info div后面。 Why is this and how can I bring the ship-info div in front of the open layers vector layers? 为什么会这样,如何将ship-info div带到开放层矢量层的前面?

Thanks. 谢谢。

I finally found the answer. 我终于找到了答案。 It's because the vectors are styled by the "map viewport" div which is created by the OpenLayers javascript. 这是因为矢量是由OpenLayers javascript创建的“地图视口” div设置样式的。 If you style the viewport's z-index, the layers will fall into place. 如果您为视口的z-index设置样式,则图层将落入适当位置。

div.olMapViewport {
     z-index: 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM