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/elements/leaflet-circle-marker.ts

32 lines
1.2 KiB
TypeScript

import { CircleMarker, type CircleMarkerOptions } from 'leaflet';
import { num, type PropDef } from '../core/props.ts';
import { latLngProps, pathProps } from '../core/shared-props.ts';
import {
WithProps,
type LeafletAddEventListener,
type LeafletElementConstructor,
type LeafletRemoveEventListener,
} from '../core/with-props.ts';
import type { PathEvents } from '../core/event-types.ts';
const PROPS: typeof latLngProps &
typeof pathProps & {
radius: PropDef<number, CircleMarker>;
} = {
...latLngProps,
radius: num<CircleMarker>(10, { get: (obj) => obj.getRadius() }),
...pathProps,
};
const Base: LeafletElementConstructor<CircleMarker, typeof PROPS> = WithProps(PROPS);
/** `<leaflet-circle-marker>` — a Leaflet `CircleMarker` (radius in pixels, fixed screen size). */
export default class LeafletCircleMarkerElement extends Base {
declare readonly leafletObject?: CircleMarker;
declare addEventListener: LeafletAddEventListener<PathEvents>;
declare removeEventListener: LeafletRemoveEventListener<PathEvents>;
createLeafletObject(options: CircleMarkerOptions): CircleMarker {
return new CircleMarker([this.lat, this.lng], options);
}
}