我目前在這裏設置:fully functional fiddle example,同時我設法縮放到每個多邊形功能我也想在每個顯示集中文本標籤...找到field_title
變量在get_fields
方法內。我不知道如何做到這一點,所有我的谷歌搜索已經拿出這篇文章:http://openlayers.org/en/v3.3.0/examples/vector-labels.html,我覺得完全混淆,因爲我是一個新的OL!Openlayers 3:添加文本標籤功能
5
A
回答
9
爲了增加ol.Feature
你將存儲在特徵和描述set a style這是一個style function文本(也將獲得從特徵描述和表現出來):
field_polygon.set('description', field_title);
field_polygon.setStyle(styleFunction);
function styleFunction() {
return [
new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255,255,255,0.4)'
}),
stroke: new ol.style.Stroke({
color: '#3399CC',
width: 1.25
}),
text: new ol.style.Text({
font: '12px Calibri,sans-serif',
fill: new ol.style.Fill({ color: '#000' }),
stroke: new ol.style.Stroke({
color: '#fff', width: 2
}),
// get the text from the feature - `this` is ol.Feature
// and show only under certain resolution
text: map.getView().getZoom() > 12 ? this.get('description') : ''
})
})
];
}
+0
這太棒了!謝謝!我如何只顯示特定縮放級別以上的文字? –
+1
查看更新的答案。 'map.getView()。getZoom()> 12? this.get('description'):''' –
+0
完美,謝謝! –
相關問題
- 1. Openlayers 3功能標籤背景
- 2. Openlayers文本標籤
- 3. 的OpenLayers 3:對齊/旋轉與行標籤功能
- 4. Openlayers 3 + GeoJson選擇功能
- 5. Openlayers 3:動畫點功能
- 6. 的OpenLayers 3 - 刪除功能
- 7. 的OpenLayers 3高亮功能
- 8. 使用TurfJS「合併」功能在OpenLayers 3中添加GeoJSON圖層
- 9. 將平移功能添加到OpenLayers中的概覽圖3
- 10. 將html標籤添加到文本禁用按鈕功能
- 11. 向drupal 7 openlayers添加更多功能
- 12. 使用Openlayers 3刷新功能3
- 13. Openlayers 3性能標記
- 14. 添加標籤計數wp_tag_cloud功能
- 15. 如何NER添加標籤功能
- 16. 添加排序功能對錶標籤
- 17. 向html5視頻標籤添加輔助功能標籤
- 18. 獲取功能陣列中的OpenLayers 3
- 19. 更新OpenLayers中的功能樣式3
- 20. Openlayers 3 - ScaleLine文本格式
- 21. py2.7標籤文本功能失敗
- 22. 標籤包括前$ PARAMS功能文本
- 23. 圖標帶有標籤或文字在openlayers 3,偏移量
- 24. 從javascript中添加標籤或添加文本框的文本
- 25. 添加文本(文件包含標籤)
- 26. 如何添加上的OpenLayers標記3捐贈座標
- 27. 在富文本編輯器中添加Tab鍵功能(Flex 3)
- 28. RiotJS 3:調用標籤功能
- 29. 標記的OpenLayers 3
- 30. 如何將jquery-ui添加到文本框?在標籤中,它的功能
您可以將動畫部分移至另一個問題嗎?它可以幫助最初的混亂。 –
@JonatasWalker完成了。謝謝。 –