如下面发布的代码所示,我创建了一个几何图形,VectorTileLayer
该几何图形VectorTileSource
是MVT
从url
属性中所述的 web 服务中检索的。数据库表包含如下所示的列。对于每个放大和缩小或拖动事件,将调用 Web 服务并根据 和 zoom 检索匹配/对应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
)
渲染特征的内容