Path
export var Path = Layer.extend({
options: {
stroke: true,
color: "#3388ff",
weight: 3,
opacity: 1,
lineCap: "round",
lineJoin: "round",
dashArray: null,
dashOffset: null,
fill: false,
fillColor: null,
fillOpacity: 0.2,
fillRule: "evenodd",
interactive: true,
bubblingMouseEvents: true,
},
beforeAdd: function (map) {
this._renderer = map.getRenderer(this);
},
onAdd: function () {
this._renderer._initPath(this);
this._reset();
this._renderer._addPath(this);
},
onRemove: function () {
this._renderer._removePath(this);
},
redraw: function () {
if (this._map) {
this._renderer._updatePath(this);
}
return this;
},
setStyle: function (style) {
Util.setOptions(this, style);
if (this._renderer) {
this._renderer._updateStyle(this);
if (
this.options.stroke &&
style &&
Object.prototype.hasOwnProperty.call(style, "weight")
) {
this._updateBounds();
}
}
return this;
},
bringToFront: function () {
if (this._renderer) {
this._renderer._bringToFront(this);
}
return this;
},
bringToBack: function () {
if (this._renderer) {
this._renderer._bringToBack(this);
}
return this;
},
getElement: function () {
return this._path;
},
_reset: function () {
this._project();
this._update();
},
_clickTolerance: function () {
return (
(this.options.stroke ? this.options.weight / 2 : 0) +
(this._renderer.options.tolerance || 0)
);
},
});
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
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
编辑 (opens new window)
上次更新: 2025/04/15, 08:40:23