maplair
Version:
JavaScript library for mobile-friendly interactive maps
68 lines (67 loc) • 1.44 kB
JavaScript
import { setOptions } from "../../core/Util.js";
import { Layer } from "../Layer.js";
//#region src/layer/vector/Path.js
var Path = class extends Layer {
static {
this.setDefaultOptions({
stroke: true,
color: "#3388ff",
weight: 3,
opacity: 1,
lineCap: "round",
lineJoin: "round",
dashArray: null,
dashOffset: null,
fill: false,
fillColor: null,
fillOpacity: .2,
fillRule: "evenodd",
interactive: true,
bubblingPointerEvents: true
});
}
beforeAdd(map) {
this._renderer = map.getRenderer(this);
}
onAdd() {
this._renderer._initPath(this);
this._reset();
this._renderer._addPath(this);
}
onRemove() {
this._renderer._removePath(this);
}
redraw() {
if (this._map) this._renderer._updatePath(this);
return this;
}
setStyle(style) {
setOptions(this, style);
if (this._renderer) {
this._renderer._updateStyle(this);
if (this.options.stroke && style && Object.hasOwn(style, "weight")) this._updateBounds();
}
return this;
}
bringToFront() {
this._renderer?._bringToFront(this);
return this;
}
bringToBack() {
this._renderer?._bringToBack(this);
return this;
}
getElement() {
return this._path;
}
_reset() {
this._project();
this._update();
}
_clickTolerance() {
return (this.options.stroke ? this.options.weight / 2 : 0) + (this._renderer.options.tolerance || 0);
}
};
//#endregion
export { Path };
//# sourceMappingURL=Path.js.map