Skip to content

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

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

Merged
merged 8 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SuperMap iClient for JavaScript 是一套由 JavaScript 语言编写的 GIS 客
## 简介
* 官网:[http://iclient.supermap.io](http://iclient.supermap.io)

* 源码:[https://github.com/SuperMap/iClient9](https://github.com/SuperMap/iClient9)
* 源码:[https://github.com/SuperMap/iClient9-JavaScript](https://github.com/SuperMap/iClient9-JavaScript)

## 许可
[ Apache License 2.0 ](./LICENSE)
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