如圖中貼在下面的代碼,我創建VectorTileLayer并且VectorTileSource是MVT被從一個web服務檢索為以所述幾何url屬性。資料庫表包含如下所示的列。對于每個放大和-out或拖動事件的web服務將被呼叫,取回匹配/根據correspnding瓷磚x,y和放大z。webservice 提供的VectorTileSource是表格的一行grid_cell_data。現在,對于每個渲染的功能,style都會呼叫該函式。我想要實作的是,可以訪問渲染功能屬性/屬性,例如isTreatment,fourCornersRepresentativeToBufferAsGeoJSON等等。我在樣式函式中添加了日志,如下所示,但下表中提到的所有列都無法訪問。換句話說,表列的名稱沒有設定為渲染特征的屬性。呈現的特征應該是包含所有資訊的一行。請讓我知道如何訪問功能屬性我還添加了一個影像,顯示了樣式功能中提到的日志的輸出。
代碼:
public visualisePolygonsAsMVTTilesOnMapWithColors(map,keyGridsAsGeoJSON,fillColor,strokeColor,text){
var vectorTile = new VectorTileLayer({
source: new VectorTileSource({
format: new MVT(),
url: environment.LocalHostForTileLayerSourceAsMVTTileForZXYWS "/{z}/{x}/{y}",
}),
style: function (feature,resolution){
console.log("feature:",feature)
console.log("feature.getProperties():",feature.getProperties())
}
});
return vectorTile;
}
postgresql 資料庫表
CREATE TABLE IF NOT EXISTS grid_cell_data (
id SERIAL PRIMARY KEY,
isTreatment boolean,
isBuffer boolean,
fourCornersRepresentativeToTreatmentAsGeoJSON text,
fourCornersRepresentativeToBufferAsGeoJSON text,
distanceFromCenterPointOfTreatmentToNearestEdge float8,
distanceFromCenterPointOfBufferToNearestEdge float8,
areasOfCoveragePerWindowForCellsRepresentativeToTreatment float8,
areasOfCoveragePerWindowForCellsRepresentativeToBuffer float8,
averageHeightsPerWindowRepresentativeToTreatment float8,
averageHeightsPerWindowRepresentativeToBuffer float8,
geometryOfCellRepresentativeToTreatment geometry,
geometryOfCellRepresentativeToBuffer geometry
)
渲染特征的內容

uj5u.com熱心網友回復:
getProperties()回傳屬性物件,所以feature.getProperties().myProperty = myValue應該可以作業,但該功能可能分布在多個圖塊上并存在于多個縮放級別,因此這不是一個好方法,最好設定一個由唯一功能 ID 索引的物件(例如作為
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/360631.html
