DivIcon
export var DivIcon = Icon.extend({
options: {
iconSize: [12, 12],
html: false,
bgPos: null,
className: "leaflet-div-icon",
},
createIcon: function (oldIcon) {
var div =
oldIcon && oldIcon.tagName === "DIV"
? oldIcon
: document.createElement("div"),
options = this.options;
if (options.html instanceof Element) {
empty(div);
div.appendChild(options.html);
} else {
div.innerHTML = options.html !== false ? options.html : "";
}
if (options.bgPos) {
var bgPos = point(options.bgPos);
div.style.backgroundPosition = -bgPos.x + "px " + -bgPos.y + "px";
}
this._setIconStyles(div, "icon");
return div;
},
createShadow: function () {
return null;
},
});
export function divIcon(options) {
return new DivIcon(options);
}
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
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
编辑 (opens new window)
上次更新: 2025/04/11, 08:35:36