forked from huiyan-fe/mapv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawer.js
More file actions
77 lines (65 loc) · 1.83 KB
/
Copy pathDrawer.js
File metadata and controls
77 lines (65 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* @author nikai (@胖嘟嘟的骨头, nikai@baidu.com)
*/
/* globals util */
function Drawer(layer) {
Class.call(this);
this.mapv = layer._mapv;
this.initOptions({
layer: layer,
map: layer.getMap(),
ctx: null,
mapv: null,
animationOptions: {},
drawOptions: {
radius: 2
}
});
this.bindTo('ctx', layer)
this.bindTo('animationOptions', layer)
this.bindTo('drawOptions', layer)
this.bindTo('mapv', layer)
this.bindTo('map', layer)
}
util.inherits(Drawer, Class);
Drawer.prototype.drawMap = function () {
};
// we need defined drawDataRange so that in Mapv.js
// we can shwo or remove range cans by drawer.drawDataRange
// Drawer.prototype.drawDataRange = function () {};
Drawer.prototype.drawOptions_changed = function () {
var drawOptions = this.getDrawOptions();
if (drawOptions && drawOptions.splitList) {
this.splitList = drawOptions.splitList;
} else {
this.generalSplitList();
}
this.drawDataRange && this.drawDataRange();
};
Drawer.prototype.colors = [
'rgba(17, 102, 252, 0.8)',
'rgba(52, 139, 251, 0.8)',
'rgba(110, 176, 253, 0.8)',
'rgba(255, 241, 193, 0.8)',
'rgba(255, 146, 149, 0.8)',
'rgba(253, 98, 104, 0.8)',
'rgba(255, 0, 0, 0.8)',
'rgba(255, 51, 61, 0.8)'
];
Drawer.prototype.generalSplitList = function () {
var dataRange = this.getLayer().getDataRange();
var splitNum = Math.ceil((dataRange.max - dataRange.min) / 7);
var index = dataRange.min;
this.splitList = [];
var radius = 1;
while (index < dataRange.max) {
this.splitList.push({
start: index,
end: index + splitNum,
radius: radius,
color: this.colors[radius - 1]
});
index += splitNum;
radius++;
}
};