Map添加Layer时js报错

0 投票

使用产品:iclient 9D 2019 for JavaScript  操作系统:win10 x64
问题详细描述:

1.在页面初始化的时候使用SuperMap.Map.addLayers,正常显示

//添加图层
map.addLayers([beijingXsmLayer, vecotrLayer]);

2.后续有需求,使用添加新的layer放置进Map中进行显示,但是在使用SuperMap.Map.addLayer方法时,浏览器控制台报错

var filterVecotrLayer = new SuperMap.Layer.Vector(paramName+"polygonLayer");
//绘制图层样式
filterVecotrLayer.style = {
		fillColor: "blue",
		fillOpacity: 1,
		hoverFillColor: "white",
		hoverFillOpacity: 0.8,
		strokeColor: "#ee9900",
		strokeOpacity: 1,
		strokeWidth: 1,
		strokeLinecap: "round",
		strokeDashstyle: "solid",
		hoverStrokeColor: "red",
		hoverStrokeOpacity: 1,
		hoverStrokeWidth: 0.2,
		pointRadius: 6,
		hoverPointRadius: 1,
		hoverPointUnit: "%",
		pointerEvents: "visiblePainted",
		cursor: "inherit",
		fontColor: "#000000",
		labelAlign: "cm",
		labelOutlineColor: "white",
		labelOutlineWidth: 3
};
vecotrLayer.display(false);
filterVecotrLayer.addFeatures(vecotrLayer.getFeaturesByAttribute(paramName,value));
//添加图层,运行完这里会出错
map.addLayer(filterVecotrLayer);

3.报错信息

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
    at d (eval at <anonymous> (http://localhost:8082/js/SuperMap-8.1.1-16520.js:3:1), <anonymous>:1:468676)
    at initialize.drawFeature (eval at <anonymous> (http://localhost:8082/js/SuperMap-8.1.1-16520.js:3:1), <anonymous>:1:468091)
    at initialize.drawFeatures (eval at <anonymous> (http://localhost:8082/js/SuperMap-8.1.1-16520.js:3:1), <anonymous>:1:464999)
    at initialize.moveTo (eval at <anonymous> (http://localhost:8082/js/SuperMap-8.1.1-16520.js:3:1), <anonymous>:1:464388)
    at initialize.redraw (eval at <anonymous> (http://localhost:8082/js/SuperMap-8.1.1-16520.js:3:1), <anonymous>:1:61942)
    at initialize.redraw (eval at <anonymous> (http://localhost:8082/js/SuperMap-8.1.1-16520.js:3:1), <anonymous>:1:465215)
    at initialize.addLayer (eval at <anonymous> (http://localhost:8082/js/SuperMap-8.1.1-16520.js:3:1), <anonymous>:1:42824)
    at filterByParam (http://localhost:8082/control/Draw.js:274:10)
    at HTMLAnchorElement.onclick (http://localhost:8082/supermap/list:32:76)

12月 10, 2018 分类:  135次浏览 | 用户: Louis (2 分)
重新分类 12月 10, 2018 用户:胡延南

1个回答

0 投票
这个目前看不出来有什么问题,您能说下整体功能的实现逻辑吗?
12月 10, 2018 用户: 于浩 名扬四海 (2,948 分)
这个是想从一个layer中,获取到含有某些attributes的features,然后重新生成一个layer进行显示,现在问题解决了,重新再新layer中绘制features的坐标点,应该是layer不能引用其他layer上已绘制好的features,因为不是同一个layer,无法引用,对吧
可以用啊。

在你重新绘制的vectoryLayer的source 使用source.addfeature(你获取的另一个layer的feature)
...