【发布时间】:2016-12-13 10:29:27
【问题描述】:
我目前正在使用 Openlayers2 开发地图。 这张地图必须显示几个信息
我已经设法使用
集成图像和画布- OpenLayers.Layer.Vector -> 用于基本图像和矢量
- OpenLayers.StyleMap 和 OpenLayers.Style -> 用于画布和文本
我现在需要插入几个框,整合文本。
盒子必须适应文本,每个文本都有不同的长度。
我现在想插入 自定义 HTML 标记,例如 div,而不是画布(难以适应且处理起来相当繁重)
信息是从 json 整合而来的:
Json 示例
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
589200.0,
2402900.0
]
},
"properties": {
"activation": "true",
"info": "one for example short text"
}
}, {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
603700.0,
2408300.0
]
},
"properties": {
"activation": "true",
"info": My other very long text \n with lines \r different messages and so on\n and it has to fit in.."
}
}]
}
这是一张遗留地图,我们被 Openlayer 2 卡住了,所以解决方案不会是版本 3。
我正在网上拼命寻找适合的解决方案,但没有成功,但我正在浪费大量宝贵的时间。
信息是这样加载的:
new OpenLayers.Layer.Vector("Vector", {
layername: "myText",
resolutions: [100, 50, 25, 10],
styleMap: textStyleMap,
isBaseLayer: false,
visibility: false,
strategies: [new OpenLayers.Strategy.Fixed({
preload: true
})],
protocol: new OpenLayers.Protocol.HTTP({
url: "myText.json",
format: new OpenLayers.Format.GeoJSON()
})
})
我可以使用什么样的 styleMap? 有没有人解决这个问题?
谢谢!
【问题讨论】:
标签: html class openlayers layer