1
我目前正在開發地圖,使用開放層2。 這張地圖顯示幾個信息將自定義div標記插入開放層
我已經成功使用每噸
- 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.."
}
}]
}
這是一箇舊的地圖,我們正在與stucked 2 Openlayer,因此該解決方案將不能與版本3
我在網上搜索desesperately將適合的解決方案,沒有成功,但我失去了寶貴的時間。
的信息被加載這樣:
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設定的? 有沒有人解決這個問題?
謝謝!