簡體   English   中英

openlayers 6 如何從文本數組中獲取值 label

[英]openlayers 6 how to get a value from an array for a text label

我正在嘗試在 openlayers 中創建 label。 (我可以做的彈出窗口)。 我的數據來自 PostgreSQL 數據庫。

我設法創建了一個具有如下值的數組:

var selectedFeatures = [];
ogc.getSource().forEachFeature(function(feature) {
  selectedFeatures.push(feature.get("id"),feature.get("datum"),feature.get("fractie"), feature.get("tijd"));
});;

現在,如何將實際特征 (id) 與數組中的正確值 (id) 匹配? 並將這個值推送到一個變量?

您可以使用 object 而不是數組,或者由 id 索引的 arrays 數組

  selectedFeatures[feature.get("id")] = [feature.get("datum"),feature.get("fractie"), feature.get("tijd")];

暫無
暫無

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

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