Skip to content

Commit 484b577

Browse files
committed
【bug】webmap调整catch中,没有代码。以及过滤问题
1 parent f79a206 commit 484b577

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class WebMap extends ol.Observable {
133133
}).then(function (response) {
134134
return response.json();
135135
}).then(function (mapInfo) {
136-
that.baseProjection = mapInfo.projection; //epsgCode是之前的数据格式 todo
136+
that.baseProjection = mapInfo.projection;
137137
that.mapParams = {
138138
title: mapInfo.title,
139139
description: mapInfo.description
@@ -325,7 +325,6 @@ export class WebMap extends ol.Observable {
325325
* @returns {ol.source.Tianditu} 天地图的source
326326
*/
327327
createTiandituSource(layerInfo, layerType, projection, isLabel) {
328-
//todo 后台存储没有存储isLabel是否有标签
329328
let options = {
330329
layerType: layerType.split('_')[1].toLowerCase(),
331330
isLabel: isLabel || false,
@@ -1018,6 +1017,7 @@ export class WebMap extends ol.Observable {
10181017
* @return {string}
10191018
*/
10201019
createGraphicLayer(layerInfo, features) {
1020+
features = layerInfo.filterCondition ? this.getFiterFeatures(layerInfo.filterCondition, features) : features;
10211021
let graphics = this.getGraphicsFromFeatures(features, layerInfo.style);
10221022
let source = new ol.source.Graphic({
10231023
graphics: graphics,
@@ -1112,15 +1112,16 @@ export class WebMap extends ol.Observable {
11121112
* @private
11131113
* @function ol.supermap.WebMap.prototype.createSymbolLayer
11141114
* @description 添加符号图层
1115-
* @param {object} features - feature的集合
1115+
* @param {object} layerInfo - 图层信息
1116+
* @param {array} features - feature的集合
11161117
* @return {object}
11171118
*/
11181119
createSymbolLayer(layerInfo, features) {
11191120
let style = this.getSymbolStyle(layerInfo.style);
11201121
return new ol.layer.Vector({
11211122
style: style,
11221123
source: new ol.source.Vector({
1123-
features: features,
1124+
features: layerInfo.filterCondition ? this.getFiterFeatures(layerInfo.filterCondition, features) : features,
11241125
wrapX: false
11251126
})
11261127
});
@@ -1136,7 +1137,6 @@ export class WebMap extends ol.Observable {
11361137
getSymbolStyle(parameters) {
11371138
let text = '';
11381139
if (parameters.unicode) {
1139-
//todo 为什么要判断,难道还有其他的图层会进来
11401140
text = String.fromCharCode(parseInt(parameters.unicode.replace(/^&#x/, ''), 16));
11411141
}
11421142
// 填充色 + 透明度
@@ -1247,7 +1247,7 @@ export class WebMap extends ol.Observable {
12471247
return new ol.layer.Vector({
12481248
style: style,
12491249
source: new ol.source.Vector({
1250-
features: features,
1250+
features: layerInfo.filterCondition ? this.getFiterFeatures(layerInfo.filterCondition, features) : features,
12511251
wrapX: false
12521252
})
12531253
});
@@ -1262,6 +1262,8 @@ export class WebMap extends ol.Observable {
12621262
* @returns {ol.layer.Heatmap}
12631263
*/
12641264
createHeatLayer(layerInfo, features) {
1265+
//因为热力图,随着过滤,需要重新计算权重
1266+
features = layerInfo.filterCondition ? this.getFiterFeatures(layerInfo.filterCondition, features) : features;
12651267
let source = new ol.source.Vector({
12661268
features: features,
12671269
wrapX: false
@@ -1292,6 +1294,7 @@ export class WebMap extends ol.Observable {
12921294
* @param {string} weightFeild - 权重字段
12931295
*/
12941296
changeWeight(features, weightFeild) {
1297+
let that = this;
12951298
this.fieldMaxValue = {};
12961299
this.getMaxValue(features, weightFeild);
12971300
let maxValue = this.fieldMaxValue[weightFeild];
@@ -1301,7 +1304,7 @@ export class WebMap extends ol.Observable {
13011304
let value = attributes[weightFeild];
13021305
feature.set('weight', value / maxValue);
13031306
} catch (e) {
1304-
// V2 热力图没有权重字段 但恢复回来却有权重字段
1307+
that.errorCallback && that.errorCallback(e);
13051308
}
13061309
})
13071310
}
@@ -1314,8 +1317,7 @@ export class WebMap extends ol.Observable {
13141317
* @param {string} weightField - 权重字段
13151318
*/
13161319
getMaxValue(features, weightField) {
1317-
let values = [],
1318-
attributes;
1320+
let values = [], that = this, attributes;
13191321
let field = weightField;
13201322
if (this.fieldMaxValue[field]) {
13211323
return;
@@ -1326,7 +1328,7 @@ export class WebMap extends ol.Observable {
13261328
try {
13271329
values.push(parseFloat(attributes[field]));
13281330
} catch (e) {
1329-
// V2 热力图没有权重字段 但恢复回来却有权重字段
1331+
that.errorCallback && that.errorCallback(e);
13301332
}
13311333
});
13321334
this.fieldMaxValue[field] = ArrayStatistic.getArrayStatistic(values, 'Maximum');
@@ -1527,7 +1529,7 @@ export class WebMap extends ol.Observable {
15271529
attributes;
15281530
let segmentCount = count;
15291531
let segmentMethod = method;
1530-
1532+
let that = this;
15311533
features.forEach(function (feature) {
15321534
attributes = feature.get("Properties") || feature.attributes;
15331535
try {
@@ -1543,7 +1545,7 @@ export class WebMap extends ol.Observable {
15431545
}
15441546
}
15451547
} catch (e) {
1546-
// console.log(e);
1548+
that.errorCallback && that.errorCallback(e);
15471549
}
15481550

15491551
});
@@ -1552,7 +1554,7 @@ export class WebMap extends ol.Observable {
15521554
try {
15531555
segements = ArrayStatistic.getArraySegments(values, segmentMethod, segmentCount);
15541556
} catch (e) {
1555-
// console.log(e);
1557+
that.errorCallback && that.errorCallback(e);
15561558
}
15571559
if (segements) {
15581560
let itemNum = segmentCount;

0 commit comments

Comments
 (0)