Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复mapv和echarts图层移除事件问题 #3

Merged
merged 8 commits into from
Dec 4, 2017
5 changes: 5 additions & 0 deletions src/leaflet/overlay/EChartsLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ export var EchartsLayer = L.Layer.extend({
this._ec.setOption(this._echartsOptions);
},

onRemove: function (map) {
// 销毁echarts实例
this._ec.dispose();
},

_initEchartsContainer: function () {
var size = this._map.getSize();
var _div = document.createElement('div');
Expand Down
23 changes: 12 additions & 11 deletions src/leaflet/overlay/MapVLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ export var MapVLayer = L.Layer.extend({
this.fire("loaded");
},

_hide: function () {
this.canvas.style.display = 'none';
},
// _hide: function () {
// this.canvas.style.display = 'none';
// },

_show: function () {
this.canvas.style.display = 'block';
},
// _show: function () {
// this.canvas.style.display = 'block';
// },

/**
* @private
Expand All @@ -67,11 +67,12 @@ export var MapVLayer = L.Layer.extend({
*/
onRemove: function (map) {
L.DomUtil.remove(this.container);
map.off({
moveend: this.draw,
zoomstart: this._hide,
zoomend: this._show
}, this);
// map.off({
// moveend: this.draw,
// zoomstart: this._hide,
// zoomend: this._show
// }, this);
this.renderer.unbindEvent();
},

/**
Expand Down
12 changes: 9 additions & 3 deletions src/leaflet/overlay/mapv/MapVRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export default class MapVRenderer extends BaseLayer {
this.canvasLayer = layer;
this.clickEvent = this.clickEvent.bind(this);
this.mousemoveEvent = this.mousemoveEvent.bind(this);
this.map.on('movestart', this.moveStartEvent.bind(this));
this.map.on('moveend', this.moveEndEvent.bind(this));
this.map.on('zoomstart', this.zoomStartEvent.bind(this));
this._moveStartEvent = this.moveStartEvent.bind(this);
this._moveEndEvent = this.moveEndEvent.bind(this);
this._zoomstart = this.zoomStartEvent.bind(this);
this.bindEvent();
}

Expand Down Expand Up @@ -72,6 +72,9 @@ export default class MapVRenderer extends BaseLayer {
map.on('mousemove', this.mousemoveEvent);
}
}
this.map.on('movestart', this._moveStartEvent);
this.map.on('moveend', this._moveEndEvent);
this.map.on('zoomstart', this._zoomstart);
}

/**
Expand All @@ -90,6 +93,9 @@ export default class MapVRenderer extends BaseLayer {
map.off('mousemove', this.mousemoveEvent);
}
}
this.map.off('movestart', this._moveStartEvent);
this.map.off('moveend', this._moveEndEvent);
this.map.off('zoomstart', this._zoomStartEvent);
}

/**
Expand Down