我正在尝试将静态图像图例放置在 map 顶部 OpenLayers map 的右下角。我试过使用绝对定位的 DIV,但它往往会被其他对象撞到(即使 z-index 很高)。
有没有办法使用 OpenLayers API 来做到这一点?我注意到 OpenMap 有一个 Layer.ScreenOverlay 方法 ( http://openspace.ordnancesurvey.co.uk/openspace/example7.html ),这正是我所需要的,但在我能找到的 OpenLayers 中不存在这样的方法。
最佳答案
我遇到过类似的问题,我想在 OpenLayers map 上放置静态图像图例。我的解决方案是使用属性元素 http://dev.openlayers.org/examples/attribution.html (查看页面源代码)。
您可以将属性更改为图像而不是文本:
'attribution': "<img src='myimage.jpg'/>"
至于改变属性在 map 上的位置,可以改变div.olControlAttribution的css属性,例如
div.olControlAttribution {
left:10em;
top:10em;
}
关于javascript - 将绝对定位的 DIV 添加到 OpenLayers map 的底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5539633/