修复 removelayer 清除交互事件的bug

fix demo
This commit is contained in:
thinkinggis 2019-08-26 15:36:59 +08:00
parent 37bf869df9
commit 2926971b31
3 changed files with 7 additions and 8 deletions

View File

@ -47,7 +47,7 @@
opacity: 0.9 opacity: 0.9
}).render(); }).render();
scene.TextLayer({ const layer2 = scene.PointLayer({
zIndex: 5 zIndex: 5
}) })
.source(data) .source(data)
@ -73,7 +73,6 @@
const popup = new L7.Popup({anchor:'left'}).setText('hello world') const popup = new L7.Popup({anchor:'left'}).setText('hello world')
const marker = new L7.Marker({color:'blue'}) const marker = new L7.Marker({color:'blue'})
.setLnglat( [120.19382669582967, 30.258134]) .setLnglat( [120.19382669582967, 30.258134])

View File

@ -54,7 +54,7 @@ window.scene = scene;
scene.on('loaded', () => { scene.on('loaded', () => {
$.get('https://gw.alipayobjects.com/os/rmsportal/epnZEheZeDgsiSjSPcCv.json', data => { $.get('https://gw.alipayobjects.com/os/rmsportal/epnZEheZeDgsiSjSPcCv.json', data => {
console.log(data); console.log(data);
const circleLayer = = scene.PointLayer({ const circleLayer = scene.PointLayer({
zIndex: 0, zIndex: 0,
}) })
.source(data,{ .source(data,{
@ -70,8 +70,8 @@ scene.on('loaded', () => {
opacity: 1 opacity: 1
}) })
.render(); .render();
scene.TextLayer({ scene.PointLayer({
zIndex: 5 zIndex: 5
}) })
.source(circleLayer.layerSource) .source(circleLayer.layerSource)
@ -91,7 +91,8 @@ scene.on('loaded', () => {
}) })
.render(); .render();
});
});
}); });
</script> </script>
</body> </body>

View File

@ -608,7 +608,7 @@ export default class Layer extends Base {
*/ */
destroy() { destroy() {
this.removeAllListeners(); this.removeAllListeners();
this.clearAllInteractions(); this.get('interacionController').clearAllInteractions();
this.clearMapEvent(); this.clearMapEvent();
if (this._object3D.type === 'composer') { if (this._object3D.type === 'composer') {
this.remove(this._object3D); this.remove(this._object3D);
@ -639,7 +639,6 @@ export default class Layer extends Base {
} }
} }
this.layerMesh.geometry = null; this.layerMesh.geometry = null;
this.layerMesh.material.dispose();
this.layerMesh.material = null; this.layerMesh.material = null;
if (this._pickingMesh) { if (this._pickingMesh) {
this._pickingMesh.children[0].geometry = null; this._pickingMesh.children[0].geometry = null;