首页 / 浏览问题 / 三维GIS / 问题详情
态势推演图层操作展示报错问题
5EXP 2025年07月29日

将保存的态势推演的信息查询出来后,进行展示,报一下错误

MGIS_SuperMap3D.js:274 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'defaultFlag')
    at new _0x317d46 (MGIS_SuperMap3D.js:274:322415)
    at _0x3541e7.<computed>.<computed> [as createSymbolByGeoJson] (MGIS_SuperMap3D.js:274:641132)
    at _0x3541e7.geoJsonToGeoGraphicObject (MGIS_SuperMap3D.js:274:638949)
    at index.vue:370:27

其加载的过程如下

deducData.forEach(function (param) {
          var plottingLayerName = "Layer_" + Math.ceil(Math.random() * 1000);
          let latestLayer = new SuperMap3D.PlottingLayer(viewer.scene, plottingLayerName);
          viewer.scene.plotLayers.add(latestLayer);
          axios.get(`${download}${param.smlFile}`).then((res) => {
            for(const feature of res.data.layerDatas[0].features){
              latestLayer.geoJsonToGeoGraphicObject(feature);
            }
          });

        })

feature 的样例格式如下

{
"version": 2,
"type": "GRAPHICOBJECT",
"libID": 22,
"code": 1001,
"localePoints": [
{
"x": 185.44574271686332,
"y": 145.07478221945431,
"z": -0.20110717099274728
},
{
"x": 189.44654417424917,
"y": 140.07466751410811,
"z": 2.876286167905982
},
{
"x": 180.44711010706602,
"y": 245.07319144267119,
"z": 0
}
],
"symbolName": "平行平耳箭头",
"symbolType": 2,
"uuid": "064b47e4-102b-4a7e-96e9-b37b232381a0",
"isEdit": false,
"scaleByMap": true,
"wholeHeight": 0,
"style": {
"lineColor": {
"alpha": 255,
"red": 255,
"green": 0,
"blue": 0
},
"fillSymbolID": 1,
"fillBackColor": {
"alpha": 255,
"red": 255,
"green": 0,
"blue": 0
},
"fillForeColor": {
"alpha": 255,
"red": 255,
"green": 0,
"blue": 0
},
"fillBackOpaque": false,
"fillGradientMode": 0,
"fillCenterOffsetX": 0,
"fillCenterOffsetY": 0,
"fillAngle": 0,
"fillOpaqueRate": 70,
"lineWidth3D": 3,
"lineWidth": 0.7937499999999998,
"display": "display",
"extendHeight": -1
},
"textStyle2D": {
"fontHeight": 5.291666666666667,
"foreColor": {
"alpha": 255,
"red": 255,
"green": 255,
"blue": 255
},
"backColor": {
"alpha": 76.5,
"red": 255,
"green": 0,
"blue": 0
},
"outline": true,
"fontStrokeColor": {
"alpha": 76.5,
"red": 255,
"green": 0,
"blue": 0
},
"backOpaque": false,
"fontBackgroundColor": {
"alpha": 204,
"red": 255,
"green": 0,
"blue": 0
},
"fontName": "宋体",
"italic": false,
"bold": true,
"align": 0,
"italicAngle": 0,
"shadow": false,
"sizeFixed": true,
"underline": false,
"rotation": 0,
"strikeout": false,
"borderSpacingWidth": 4,
"outlineWidth": 0.26458333333333334,
"fontWidth": 0,
"opaqueRate": 255,
"stringAlignment": 0,
"fontScale": 1,
"fontWeight": 0
},
"textStyle3D": {
"foreColor": {
"alpha": 255,
"red": 255,
"green": 255,
"blue": 255
},
"backColor": {
"alpha": 76.5,
"red": 255,
"green": 0,
"blue": 0
},
"outline": true,
"textBoxColor": {
"red": 1,
"green": 0,
"blue": 0,
"alpha": 0.3
},
"textBoxLineColor": {
"red": 1,
"green": 0,
"blue": 0,
"alpha": 0.8
},
"fontName": "宋体",
"italic": false,
"bold": true,
"align": 0,
"fontSize": 20,
"isShowTextBox": false
},
"surroundLineColor": {
"alpha": 255,
"red": 255,
"green": 255,
"blue": 0
},
"surroundLineType": 0,
"surroundlineWidth3D": 3,
"surroundLineWidth2D": 0.7937499999999998,
"updateSubSize": false,
"subSymbolSize": 0.00019022713143128524,
"subSymbols": [],
"dashLines": [],
"scaleValues": [
0.1,
0.2,
0,
0.3,
0.08
],
"subSymbolScaleValue": 0.1,
"wallOpaqueRate": 70,
"isClampToGround": false,
"disableDepthTestDistance": 0,
"_CenterPosition": {
"x": 187.44642302521484,
"y": 143.07401049461243,
"z": 0
},
"textContent": "",
"markHalo": false,
"showTipLength": 100,
"extendProperty": {
"properties": [],
"CLASS_NAME": "ExtendProperty"
},
"annotationArray": []
}

问题关闭原因: 不是问题

1个回答

您好,该问题是由于plottingLayerName重复导致,在new SuperMap3D.PlottingLayer(scene, layerName)中请务必为layerName定义唯一值。

另外考虑到性能问题,建议参考以下代码,在循环外定义一个PlottingLayer即可。希望能帮到您!

const latestLayer= new SuperMap3D.PlottingLayer(viewer.scene, 'plottingLayer');
 viewer.scene.plotLayers.add(latestLayer);
deducData.forEach(function (param) {
          axios.get(`${download}${param.smlFile}`).then((res) => {
            for(const feature of res.data.layerDatas[0].features){
              latestLayer.geoJsonToGeoGraphicObject(feature);
            }
          });

        })

35EXP 2025年07月29日
plottingLayerName是随机生成的,不存在重复的问题,我测试的数据只有一个,没有重复的理由,我将其移出到循环外面,问题并没有得到解决
...