Skip to content

Commit 749ea7c

Browse files
authored
Merge pull request #3 from shanligang/master
修复mapv和echarts图层移除事件问题
2 parents a3c4b08 + abe3f36 commit 749ea7c

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

src/leaflet/overlay/EChartsLayer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ export var EchartsLayer = L.Layer.extend({
146146
this._ec.setOption(this._echartsOptions);
147147
},
148148

149+
onRemove: function (map) {
150+
// 销毁echarts实例
151+
this._ec.dispose();
152+
},
153+
149154
_initEchartsContainer: function () {
150155
var size = this._map.getSize();
151156
var _div = document.createElement('div');

src/leaflet/overlay/MapVLayer.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ export var MapVLayer = L.Layer.extend({
5151
this.fire("loaded");
5252
},
5353

54-
_hide: function () {
55-
this.canvas.style.display = 'none';
56-
},
54+
// _hide: function () {
55+
// this.canvas.style.display = 'none';
56+
// },
5757

58-
_show: function () {
59-
this.canvas.style.display = 'block';
60-
},
58+
// _show: function () {
59+
// this.canvas.style.display = 'block';
60+
// },
6161

6262
/**
6363
* @private
@@ -67,11 +67,12 @@ export var MapVLayer = L.Layer.extend({
6767
*/
6868
onRemove: function (map) {
6969
L.DomUtil.remove(this.container);
70-
map.off({
71-
moveend: this.draw,
72-
zoomstart: this._hide,
73-
zoomend: this._show
74-
}, this);
70+
// map.off({
71+
// moveend: this.draw,
72+
// zoomstart: this._hide,
73+
// zoomend: this._show
74+
// }, this);
75+
this.renderer.unbindEvent();
7576
},
7677

7778
/**

src/leaflet/overlay/mapv/MapVRenderer.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export default class MapVRenderer extends BaseLayer {
3030
this.canvasLayer = layer;
3131
this.clickEvent = this.clickEvent.bind(this);
3232
this.mousemoveEvent = this.mousemoveEvent.bind(this);
33-
this.map.on('movestart', this.moveStartEvent.bind(this));
34-
this.map.on('moveend', this.moveEndEvent.bind(this));
35-
this.map.on('zoomstart', this.zoomStartEvent.bind(this));
33+
this._moveStartEvent = this.moveStartEvent.bind(this);
34+
this._moveEndEvent = this.moveEndEvent.bind(this);
35+
this._zoomstart = this.zoomStartEvent.bind(this);
3636
this.bindEvent();
3737
}
3838

@@ -72,6 +72,9 @@ export default class MapVRenderer extends BaseLayer {
7272
map.on('mousemove', this.mousemoveEvent);
7373
}
7474
}
75+
this.map.on('movestart', this._moveStartEvent);
76+
this.map.on('moveend', this._moveEndEvent);
77+
this.map.on('zoomstart', this._zoomstart);
7578
}
7679

7780
/**
@@ -90,6 +93,9 @@ export default class MapVRenderer extends BaseLayer {
9093
map.off('mousemove', this.mousemoveEvent);
9194
}
9295
}
96+
this.map.off('movestart', this._moveStartEvent);
97+
this.map.off('moveend', this._moveEndEvent);
98+
this.map.off('zoomstart', this._zoomStartEvent);
9399
}
94100

95101
/**

0 commit comments

Comments
 (0)