|
|
@@ -88,10 +88,15 @@ class WaterLayer {
|
|
|
if (this.waterLayer) {
|
|
|
this.waterLayer.source.clear();
|
|
|
}
|
|
|
- if (arr.length > 0) {
|
|
|
+ if (arr && arr.length > 0) {
|
|
|
for (let item of arr) {
|
|
|
+ if (!item || !item.geom) {
|
|
|
+ continue; // 跳过无效数据
|
|
|
+ }
|
|
|
let feature = newAreaFeature(item);
|
|
|
- this.waterLayer.addFeature(feature);
|
|
|
+ if (feature) {
|
|
|
+ this.waterLayer.addFeature(feature);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// this.fitView();
|
|
|
@@ -101,10 +106,15 @@ class WaterLayer {
|
|
|
if (this.riverLayer) {
|
|
|
this.riverLayer.source.clear();
|
|
|
}
|
|
|
- if (arr.length > 0) {
|
|
|
+ if (arr && arr.length > 0) {
|
|
|
for (let item of arr) {
|
|
|
+ if (!item || !item.geom) {
|
|
|
+ continue; // 跳过无效数据
|
|
|
+ }
|
|
|
let feature = newAreaFeature(item);
|
|
|
- this.riverLayer.addFeature(feature);
|
|
|
+ if (feature) {
|
|
|
+ this.riverLayer.addFeature(feature);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -112,10 +122,15 @@ class WaterLayer {
|
|
|
if (this.canalLayer) {
|
|
|
this.canalLayer.source.clear();
|
|
|
}
|
|
|
- if (arr.length > 0) {
|
|
|
+ if (arr && arr.length > 0) {
|
|
|
for (let item of arr) {
|
|
|
+ if (!item || !item.geom) {
|
|
|
+ continue; // 跳过无效数据
|
|
|
+ }
|
|
|
let feature = newAreaFeature(item);
|
|
|
- this.canalLayer.addFeature(feature);
|
|
|
+ if (feature) {
|
|
|
+ this.canalLayer.addFeature(feature);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|