maplair
Version:
JavaScript library for mobile-friendly interactive maps
69 lines (68 loc) • 1.76 kB
JavaScript
import { setOptions } from "../../core/Util.js";
import { Bounds } from "../../geometry/Bounds.js";
import { LatLng } from "../../geo/LatLng.js";
import { Path } from "./Path.js";
//#region src/layer/vector/CircleMarker.js
var CircleMarker = class CircleMarker extends Path {
static {
this.setDefaultOptions({
fill: true,
radius: 10
});
}
constructor(latlng, options) {
super();
setOptions(this, options);
this._latlng = new LatLng(latlng);
this._radius = this.options.radius;
this.callInitHooks(CircleMarker);
}
setLatLng(latlng) {
const oldLatLng = this._latlng;
this._latlng = new LatLng(latlng);
this.redraw();
return this.fire("move", {
oldLatLng,
latlng: this._latlng
});
}
getLatLng() {
return this._latlng;
}
setRadius(radius) {
this.options.radius = this._radius = radius;
return this.redraw();
}
getRadius() {
return this._radius;
}
setStyle(options) {
super.setStyle(options);
if (options?.radius !== void 0) this.setRadius(options.radius);
return this;
}
_project() {
this._point = this._map.latLngToLayerPoint(this._latlng);
this._pxRadius = this._radius;
this._updateBounds();
}
_updateBounds() {
const r = this._pxRadius, r2 = this._pxRadiusY ?? r, w = this._clickTolerance(), p = [r + w, r2 + w];
this._pxBounds = new Bounds(this._point.subtract(p), this._point.add(p));
}
_update() {
if (this._map) this._updatePath();
}
_updatePath() {
this._renderer._updateCircle(this);
}
_empty() {
return this._pxRadius && !this._renderer._bounds.intersects(this._pxBounds);
}
_containsPoint(p) {
return p.distanceTo(this._point) <= this._pxRadius + this._clickTolerance();
}
};
//#endregion
export { CircleMarker };
//# sourceMappingURL=CircleMarker.js.map