import { Circle, type CircleOptions } from 'leaflet'; import { num, positional } from '../core/props.ts'; import { latLngProps, pathProps } from '../core/shared-props.ts'; import { WithProps } from '../core/with-props.ts'; export class LeafletCircle extends WithProps({ ...latLngProps, ...pathProps, // Leaflet has no default radius -- it throws without one -- so unlike every // other option, this one is always passed, from the default when unset. radius: positional(num(1000, { get: (obj) => obj.getRadius() })), }) { declare readonly leafletObject?: Circle; createLeafletObject(options: CircleOptions): Circle { return new Circle([this.lat, this.lng], { ...options, radius: this.radius }); } } customElements.define('leaflet-circle', LeafletCircle);