You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
leaflet-components/src/components/leaflet-circle.ts

21 lines
785 B
TypeScript

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<Circle>(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);