修改代码
This commit is contained in:
parent
257945d203
commit
3a0e467221
@ -2,7 +2,6 @@ import * as zrUtil from 'zrender/src/core/util';
|
||||
import zrender from 'zrender';
|
||||
import Painter from './painter';
|
||||
import Options from './options';
|
||||
import ProxyHandle from './proxyHandle';
|
||||
import MouseController from './mouseController';
|
||||
import deviceState from './constant/deviceState';
|
||||
import { selectSkinStyle } from './config/deviceStyle';
|
||||
@ -32,9 +31,6 @@ class Jmap {
|
||||
// 设备数据
|
||||
this.mapDevice = {};
|
||||
|
||||
// 代理数据
|
||||
this.proxyData = {};
|
||||
|
||||
// 默认状态
|
||||
this.defaultStateDict = this.loadDefaultState();
|
||||
|
||||
@ -75,9 +71,6 @@ class Jmap {
|
||||
// 解析地图数据
|
||||
this.mapDevice = parser(data, this);
|
||||
|
||||
// 生成代理对象
|
||||
this.proxyData = new Proxy(this.mapDevice, new ProxyHandle(this.$painter));
|
||||
|
||||
// 数据加载完成
|
||||
if (this.methods.dataLoaded instanceof Function) { this.methods.dataLoaded(); }
|
||||
|
||||
@ -151,11 +144,13 @@ class Jmap {
|
||||
(list || []).forEach(elem => {
|
||||
const type = elem.type;
|
||||
const code = elem.code;
|
||||
const device = this.proxyData[code] || deviceFactory(type, this.styleDict[type], elem);
|
||||
const model = Object.assign(device.model || {}, elem);
|
||||
delete this.proxyData[code];
|
||||
const oDevice = this.mapDevice[code] || deviceFactory(type, this.styleDict[type], elem);
|
||||
const model = Object.assign(oDevice.model || {}, elem);
|
||||
this.$painter.delete(oDevice);
|
||||
if (!elem._dispose) {
|
||||
this.proxyData[code] = Object.assign(device, { model });
|
||||
const nDevice = Object.assign(oDevice, { model });
|
||||
this.mapDevice[code] = nDevice;
|
||||
this.$painter.add(nDevice);
|
||||
}
|
||||
|
||||
this.dataSync(model);
|
||||
@ -168,11 +163,13 @@ class Jmap {
|
||||
(list || []).forEach(elem => {
|
||||
const code = elem.code;
|
||||
if (elem._dispose) {
|
||||
delete this.proxyData[code];
|
||||
delete this.mapDevice[code];
|
||||
} else {
|
||||
const device = this.proxyData[code] || {};
|
||||
const state = Object.assign(device.state || {}, elem);
|
||||
this.proxyData[code] = Object.assign(device, { state });
|
||||
const oDevice = this.mapDevice[code] || {};
|
||||
const state = Object.assign(oDevice.state || {}, elem);
|
||||
const nDevice = Object.assign(oDevice, { state });
|
||||
this.mapDevice[code] = nDevice;
|
||||
this.$painter.update(nDevice);
|
||||
}
|
||||
});
|
||||
|
||||
@ -263,7 +260,6 @@ class Jmap {
|
||||
this.skinStyle = '';
|
||||
this.styleDict = {};
|
||||
this.mapDevice = {};
|
||||
this.proxyData = {};
|
||||
|
||||
this.$mouseController.dispose();
|
||||
this.$zr && zrender.dispose(this.$zr);
|
||||
|
@ -2,7 +2,7 @@ import * as zrUtil from 'zrender/src/core/util';
|
||||
import Group from 'zrender/src/container/Group';
|
||||
import deviceType from './constant/deviceType';
|
||||
import shapefactory from './shape/factory';
|
||||
import ZoomHandle from './zoomHandle';
|
||||
import Transform from './transform';
|
||||
|
||||
class Painter {
|
||||
constructor(jmap) {
|
||||
@ -11,7 +11,7 @@ class Painter {
|
||||
this.$zr = jmap.getZr();
|
||||
|
||||
// 视图控制器
|
||||
this.$zoomHandle = new ZoomHandle(this, this.$zr);
|
||||
this.$transform = new Transform(this, this.$zr);
|
||||
|
||||
// 图层数据
|
||||
this.mapInstanceLevel = {};
|
||||
@ -63,7 +63,7 @@ class Painter {
|
||||
const type = device._type;
|
||||
const instance = shapefactory(type, device, this.$jmap);
|
||||
if (instance) {
|
||||
this.$zoomHandle.transformView(instance);
|
||||
this.$transform.transformView(instance);
|
||||
device.instance = instance;
|
||||
this.mapInstanceLevel[type].add(instance);
|
||||
}
|
||||
@ -97,7 +97,7 @@ class Painter {
|
||||
* @param {*} zoom
|
||||
*/
|
||||
updateZoomTransform(zoom) {
|
||||
this.$zoomHandle.updateTransform(zoom);
|
||||
this.$transform.updateTransform(zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,24 +0,0 @@
|
||||
class ProxyHandle {
|
||||
constructor(painter) {
|
||||
this.$painter = painter;
|
||||
}
|
||||
|
||||
set(target, code, device) {
|
||||
if (device.instance) {
|
||||
this.$painter.update(device);
|
||||
} else {
|
||||
this.$painter.add(device);
|
||||
}
|
||||
return Reflect.set(target, code, device);
|
||||
}
|
||||
|
||||
deleteProperty(target, code) {
|
||||
const device = target[code];
|
||||
if (device) {
|
||||
this.$painter.delete(target[code]);
|
||||
}
|
||||
return Reflect.deleteProperty(target, code);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProxyHandle;
|
@ -19,7 +19,7 @@ function createBoundingRect(view) {
|
||||
return rect;
|
||||
}
|
||||
|
||||
class ZoomHandle {
|
||||
class TransformHandle {
|
||||
constructor(painter, zr) {
|
||||
this.$painter = painter;
|
||||
this.$zr = zr;
|
||||
@ -83,4 +83,4 @@ class ZoomHandle {
|
||||
}
|
||||
}
|
||||
|
||||
export default ZoomHandle;
|
||||
export default TransformHandle;
|
Loading…
Reference in New Issue
Block a user