import { JsonObject, JsonProperty } from 'typescript-json-serializer'; import Style from 'ol/style/Style' import Feature from 'ol/Feature' import CircleStyle from 'ol/style/Circle' import Point from 'ol/geom/Point' import Fill from 'ol/style/Fill' import Stroke from 'ol/style/Stroke' @JsonObject() export default class MapNode { private feature: Feature | null = null; constructor( @JsonProperty() private uuid: string, @JsonProperty() private coordinate_1: number, @JsonProperty() private coordinate_2: number, @JsonProperty() private type: string, @JsonProperty() private name: string, @JsonProperty() private description: string, @JsonProperty() private kind: string, ) { } public getType(): string { return this.type; } public getName(): string { return this.name; } public getDescription(): string { return this.description; } public getId(): string { return 'node-' + this.uuid; } public getFeature(): Feature { if (this.feature === null) { console.log(this.coordinate_1); console.log(this.coordinate_2); this.feature = new Feature({ geometry: new Point([this.coordinate_1, this.coordinate_2]), type: 'node-' + this.uuid, }) } return this.feature; } public getStyle(): Style { return new Style({ image: new CircleStyle({ radius: 14, fill: new Fill({color: 'white'}), stroke: new Stroke({ color: 'gray', width: 2, }) }) }); } }