* @private * @function WebMap.prototype.updateFeaturesToMap * @description 更新地图上的feature,适用于专题图 * @param {Object} layerInfo - 图层信息 * @param {number} index 图层的顺序
(layerInfo, layerIndex)
| 3017 | * @param {number} index 图层的顺序 |
| 3018 | */ |
| 3019 | updateFeaturesToMap(layerInfo, layerIndex) { |
| 3020 | let that = this, |
| 3021 | dataSource = layerInfo.dataSource, |
| 3022 | url = layerInfo.dataSource.url, |
| 3023 | dataSourceName = dataSource.dataSourceName || layerInfo.name; |
| 3024 | |
| 3025 | if (dataSource.type === 'USER_DATA' || dataSource.accessType === 'DIRECT') { |
| 3026 | that.addGeojsonFromUrl(layerInfo, null, layerIndex); |
| 3027 | } else { |
| 3028 | let requestUrl = that.formatUrlWithCredential(url), |
| 3029 | serviceOptions = {}; |
| 3030 | serviceOptions.withCredentials = that.isCredentail(requestUrl); |
| 3031 | if ( |
| 3032 | that.isAddProxy(requestUrl) |
| 3033 | ) { |
| 3034 | serviceOptions.proxy = this.getProxy(); |
| 3035 | } |
| 3036 | //因为itest上使用的https,iserver是http,所以要加上代理 |
| 3037 | getFeatureBySQL( |
| 3038 | requestUrl, |
| 3039 | [dataSourceName], |
| 3040 | serviceOptions, |
| 3041 | async function (result) { |
| 3042 | let features = that.parseGeoJsonData2Feature({ |
| 3043 | allDatas: { |
| 3044 | features: result.result.features.features |
| 3045 | }, |
| 3046 | fileCode: layerInfo.projection, |
| 3047 | featureProjection: that.baseProjection |
| 3048 | }); |
| 3049 | //删除之前的图层和标签图层 |
| 3050 | that.map.removeLayer(layerInfo.layer); |
| 3051 | layerInfo.labelLayer && that.map.removeLayer(layerInfo.labelLayer); |
| 3052 | await that.addLayer(layerInfo, features, layerIndex); |
| 3053 | }, |
| 3054 | function (err) { |
| 3055 | that.errorCallback && that.errorCallback(err, 'autoUpdateFaild', that.map); |
| 3056 | }, |
| 3057 | undefined, |
| 3058 | this.restDataSingleRequestCount |
| 3059 | ); |
| 3060 | } |
| 3061 | } |
| 3062 | |
| 3063 | /** |
| 3064 | * @private |
no test coverage detected