0

如中所示code2,我有keygridsAsGeoJSON其中包含一些特征的坐标,如code1我正在使用的 geojson.inVectorTileLayerVectorTileSource。我现在遇到的问题是,我想将数组中的功能添加keygridsAsGeoJSONVectorTileSource. 我用谷歌搜索了一些问题和文章,但不幸的是,我找不到任何示例来演示如何将功能添加到VectorTileSource

请让我知道我怎样才能做到这一点。

代码1

public visualisePolygonsAsMVTTilesOnMapWithColors(map,arrayOfPolygonsAsGeoJSON,fillColor,strokeColor,text){
    var features = [];
    arrayOfPolygonsAsGeoJSON.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({featureClass: Feature}),//<===================
            url: "http://127.0.0.1:5000/mvtTilesForVectorLayerSource/{z}/{x}/{y}",
             features: features,
            featureClass: Feature //<===================
        }),
        style: new Style ({
                  fill: new Fill({
                      color: fillColor
                      }),
                      stroke: new Stroke({
                          color: strokeColor,                   
                          width: 3
                      })                                
                  })
      });
    return vectorTile;
    }

代码2

    for (let i = 0;i <this.keygridsAsGeoJSON.length;i++) {
    
    if (this.areaOfCoveragePerWindowSegment[i] >= 0 && this.areaOfCoveragePerWindowSegment[i] <=9) {
        this.vectorLayer = this.openLayersAPIService.visualisePolygonsAsMVTTilesOnMapWithColors(this.map,[this.keygridsAsGeoJSON[i]['features'][0]['geometry']],AreaOfCoverageColorEnum2.WHITE_0,GridCellsColorEnum.RED,text)
        this.openLayersAPIService.addLayerToMap(this.map, this.vectorLayer)
    } else if(this.areaOfCoveragePerWindowSegment[i] >= 10 && this.areaOfCoveragePerWindowSegment[i] <=19) {
        this.vectorLayer = this.openLayersAPIService.visualisePolygonsAsMVTTilesOnMapWithColors(this.map,[this.keygridsAsGeoJSON[i]['features'][0]['geometry']],AreaOfCoverageColorEnum2.WHITE_1,GridCellsColorEnum.RED,text)
        this.openLayersAPIService.addLayerToMap(this.map, this.vectorLayer)
    } else if(this.areaOfCoveragePerWindowSegment[i] >= 20 && this.areaOfCoveragePerWindowSegment[i] <=29) {
        this.vectorLayer = this.openLayersAPIService.visualisePolygonsAsMVTTilesOnMapWithColors(this.map,[this.keygridsAsGeoJSON[i]['features'][0]['geometry']],AreaOfCoverageColorEnum2.WHITE_2,GridCellsColorEnum.RED,text)
        this.openLayersAPIService.addLayerToMap(this.map, this.vectorLayer)
        }
    }
4

0 回答 0