12345678910111213141516171819202122232425262728293031323334353637 |
- import { Attrib, CustomizeShape, ShapeType } from "../../type";
- import { Entity, EntityProps } from "../entity";
- import { defaultPoiShapeFactory, poiTypes } from "./types";
- type PoiData = {
- x: number;
- y: number;
- type: string;
- };
- export type PoiAttrib = Attrib & PoiData;
- export class Poi<T extends PoiAttrib = PoiAttrib> extends Entity<T, ShapeType> {
- static namespace = "poi";
- constructor(props: EntityProps<T>) {
- props.zIndex = props.zIndex || 5;
- props.name = props.name || Poi.namespace + props.attrib.id;
- super(props);
- }
- actShape: CustomizeShape<PoiData, ShapeType, { getSize: () => number[] }>;
- initShape() {
- const factory = poiTypes[this.attrib.type] || defaultPoiShapeFactory;
- this.actShape = factory(this.attrib, this);
- return this.actShape.shape;
- }
- diffRedraw() {
- this.actShape.setData(this.attrib);
- }
- mounted(): void {
- super.mounted();
- this.actShape.common(null);
- }
- }
|