在下面发布的代码中,我想将参数keyGridsAsGeoJSON
作为输入传递给style
属性中的函数。每次打印其值时k
,var k = keyGridsAsGeoJSON
我都会收到下面发布的值。我希望它k
包含包含在keyGridsAsGeoJSON
. 中的值keyGridsAsGeoJSON
如下图所示。
请让我知道为什么内容k
不是keyGridsAsGeoJSON
k 的值:
k: RenderFeature {id_: undefined, type_: 'Polygon', flatCoordinates_: Array(10), flatInteriorPoints_: null, flatMidpoints_: null, …}
ends_: [10]
flatCoordinates_: (10) [738401.380994772, 6643445.99157804, 738417.2804938197, 663446.495435405, 38417.7843511839, 643430.558613589, 738401.035135203, 6643430.054756225, 73841.3809947722, 643445.99157804]
flatInteriorPoints_: null
flatMidpoints_: null
id_: undefined
properties_: {layer: 'default'}
type_: "Polygon"
[[Prototype]]: Object
代码:
public visualisePolygonsAsMVTTilesOnMapWithColors(map,keyGridsAsGeoJSON,fillColor,strokeColor,text){
var features = [];
var iter = 0
var k = keyGridsAsGeoJSON
console.log("keyGridsAsGeoJSON:",keyGridsAsGeoJSON)
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}"
}),
style: function (k){
console.log("features:",features)
console.log("k:",k)
}
});
return vectorTile;
}