我想根据 redered-feature 中的特定功能进行动态功能样式设置。keyGridsAsGeoJSON
是一个数组,其中每个元素是一个featureCollection
包含网格单元四个角的坐标。我想知道如何style-function
查看/绑定到/到keyGridsAsGeoJSON
featureCollection 数组,以便我可以根据特定功能更改样式。如代码所示,我还希望能够根据封装在areaOfCoveragePerWindowSegment
我参考了以下帖子,但没有一个显示如何绑定或链接style-function
到功能数组,keyGridsAsGeoJSON
例如:
1
2
3
代码
public visualisePolygonsAsMVTTilesOnMapWithColors(map,keyGridsAsGeoJSON,areaOfCoveragePerWindowSegment,fillColor,strokeColor,text){
var features = [];
keyGridsAsGeoJSON.forEach(function(keyGridAsGeoJSON) {
let polygonGeometry = [keyGridAsGeoJSON['features'][0]['geometry']]
polygonGeometry.forEach(function(geojson) {
var geometry = new GeoJSON().readGeometry(geojson, {
dataProjection: 'EPSG:4326',
featureProjection: map.getView().getProjection(),
});
features.push(new Feature(geometry));
});
});
var vectorTile = new VectorTileLayer({
source: new VectorTileSource({
format: new MVT(),
url: environment.LocalHostForTileLayerSourceAsMVTTileForZXYWS + "/{z}/{x}/{y}"
// features: features
}),
style: function (renderedFeature,resolution){
console.log("features:",features)
console.log("keyGridsAsGeoJSON:",keyGridsAsGeoJSON)
console.log("renderedFeature:",renderedFeature)
console.log("areaOfCoveragePerWindowSegment:",areaOfCoveragePerWindowSegment)
for(let i=0;i<areaOfCoveragePerWindowSegment.length;i++) {
if (areaOfCoveragePerWindowSegment[i] == 1) {
return waterStyle;
} else if(areaOfCoveragePerWindowSegment[i] == 91) {
return buildingStyle;
} else {
return defaultStyle;
}
}
}
});
return vectorTile;
}