import { FeatureLike } from "ol/Feature"; import { Fill, Stroke, Style } from "ol/style"; import CircleStyle from "ol/style/Circle"; import log from "../utils/Log"; const highlightedPoint = new Style({ image: new CircleStyle({ radius: 4, fill: new Fill({ color: "rgba(255, 0, 255)" }), }), }); const highlightedLine = new Style({ stroke: new Stroke({ color: "rgb(255, 0, 255)", width: 2, }), }); const highlightedPolygon = new Style({ fill: new Fill({ color: "rgba(255, 0, 255, 0.3)", }), }); export const highlightStyleFunction = ( feature: FeatureLike ): Style | Style[] => { const geomType = feature.getGeometry()?.getType(); log.debug(`highlightStyleFunction ${JSON.stringify(feature)}`); if (geomType === "Polygon" || geomType === "MultiPolygon") { return highlightedPolygon; } if (geomType === "LineString" || geomType === "MultiLineString") { return highlightedLine; } if (geomType === "Point" || geomType === "MultiPoint") { return highlightedPoint; } return highlightedPoint; };