首页 / 浏览问题 / WebGIS / 问题详情
OpenLayers 页面添加过多矢量要素渲染卡顿
11EXP 2022年11月18日
使用产品:SuperMap iClient for OpenLayers 10i 问题详细描述: 根据id选择数据服务中的要素,并加载到地图上,才一千多个矢量面要素就出现明显卡顿,有没有什么优化的办法? //根据行政区选择展示合流制地块边界 showRegionCombinedBoundary(){ let _this = this; querycombinedinformation().then((res) => { let list = res.data.combineds; let combinedids = []; for (var i = 0; i < list.length; i++) { if (_this.inputRegion == list[i].combinedregion) { combinedids.push(list[i].combinedid) _this.combinedareas += list[i].combinedarea; } } _this.combinednumbers = combinedids.length; var idsParam = new GetFeaturesByIDsParameters({ IDs: combinedids, datasetNames: ["SZSS_KJ:PS_GWZZDiKuai"], toIndex: 100000, }); new FeatureService(this.shujuURL).getFeaturesByIDs( idsParam, this.featurecombinedregionresult ); }); }, //行政区合流制地块图层 featurecombinedregionresult(serviceResult){ window.olMap.removeLayer(this.regionCombinedLayer); var vectorSource = new VectorSource({ features: new GeoJSON().readFeatures(serviceResult.result.features), wrapX: false, }) this.regionCombinedLayer = new VectorLayer({ source: vectorSource, style: new Style({ stroke: new Stroke({ color: "#C3BD97", width: 3, }), fill: new Fill({ color: "rgba(195, 189, 151, 0.2)", }), }), zIndex: 2000, }); window.olMap.addLayer(this.regionCombinedLayer); },

2 个回答

   //根据行政区选择展示合流制地块边界
    showRegionCombinedBoundary(){
       let _this = this;
      querycombinedinformation().then((res) => {
        let list = res.data.combineds;
        let combinedids = [];
        for (var i = 0; i < list.length; i++) {
          if (_this.inputRegion == list[i].combinedregion) {
            combinedids.push(list[i].combinedid)
            _this.combinedareas += list[i].combinedarea;
            }
        }
        _this.combinednumbers = combinedids.length;
        var idsParam = new GetFeaturesByIDsParameters({
              IDs: combinedids,
              datasetNames: ["SZSS_KJ:PS_GWZZDiKuai"],
              toIndex: 100000,
            });
        new FeatureService(this.shujuURL).getFeaturesByIDs(
              idsParam,
              this.featurecombinedregionresult
            );
      });
    },
    //行政区合流制地块图层
    featurecombinedregionresult(serviceResult){
      window.olMap.removeLayer(this.regionCombinedLayer);
      var vectorSource = new VectorSource({
        features: new GeoJSON().readFeatures(serviceResult.result.features),
        wrapX: false,
      })
      this.regionCombinedLayer = new VectorLayer({
        source: vectorSource,
        style: new Style({
          stroke: new Stroke({
            color: "#C3BD97",
            width: 3,
          }),
          fill: new Fill({
            color: "rgba(195, 189, 151, 0.2)",
          }),
        }),
        zIndex: 2000,
      });
      window.olMap.addLayer(this.regionCombinedLayer);
    },

11EXP 2022年11月18日
您好,您可以通过查看请求的时间,分析是请求时间过长,还是渲染时间过长。如果渲染时间过长,可以采取:

1、如果是线面数据的points过多,可以在iDesktop中将数据进行重采样,减少节点数量;

2、可以修改iServer的jar包中的配置文件,将返回结果格式从feature改为GeoJSON格式。

希望可以给您提供帮助!
431EXP 2022年11月18日
...