簡體   English   中英

OpenLayers 3點文字zIndex

[英]OpenLayers 3 point text zIndex

文本似乎不尊重圖像的zIndex。 如果在同一個坐標中有多個點(堆疊的點),則每個點的文本將在彼此之上渲染,並中斷設計。

有沒有辦法使圖像和文本尊重其相同的zIndex位置?

我發現此OpenLayers 3圖片和文字樣式zindex ,但未提供解決方案

這是我的代碼:

new ol.style.Style({
            image: new ol.style.Circle({
                radius: 3,
                scale: 0.5,
                fill: new ol.style.Fill({
                    color: 'green'
                })
            }),
            text: new ol.style.Text({
                font: 'helvetica,sans-serif',
                text: 'here is the text',
                fill: new ol.style.Fill({
                    color: 'white'
                })
            }),
            zIndex: 10
        })

在將點符號與文本堆疊時,如果希望文本粘貼在符號上,則需要給每個點自己的zIndex (遞增)。 參見http://jsfiddle.net/8g1vayvc/ 您也可以在樣式函數中執行此操作:

var myStyle = new ol.style.Style({/*...*/});
var zIndex = 0;
function styleFunction(feature, resolution) {
  myStyle.setZIndex(zIndex++);
  return myStyle;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM