0

在下面发布的代码中,我想将参数keyGridsAsGeoJSON作为输入传递给style属性中的函数。每次打印其值时kvar k = keyGridsAsGeoJSON我都会收到下面发布的值。我希望它k包含包含在keyGridsAsGeoJSON. 中的值keyGridsAsGeoJSON如下图所示。

请让我知道为什么内容k不是keyGridsAsGeoJSON

中的值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;
}
4

0 回答 0