diff --git a/elements/map/main.ts b/elements/map/main.ts index c6e5f2eb4..b30166f42 100644 --- a/elements/map/main.ts +++ b/elements/map/main.ts @@ -5,7 +5,7 @@ import View from "ol/View.js"; // @ts-ignore import olCss from "ol/ol.css?inline"; import { DrawOptions, addDraw } from "./src/draw"; -import { SelectOptions, addSelect } from "./src/select"; +import { EoxSelectInteraction, SelectOptions, addSelect } from "./src/select"; import { generateLayers, EoxLayer, @@ -72,6 +72,12 @@ export class EOxMap extends LitElement { @state() interactions: { [index: string]: Draw | Modify } = {}; + /** + * dictionary of select interactions. + */ + @state() + selectInteractions: { [index: string]: EoxSelectInteraction } = {}; + /** * dictionary of ol controls associated with the map. */ @@ -128,7 +134,7 @@ export class EOxMap extends LitElement { }; /** - * removes a given interaction from the map. Layer have to be removed seperately + * removes a given ol-interaction from the map. Layer have to be removed seperately * @param id id of the interaction */ removeInteraction = (id: string) => { @@ -136,6 +142,15 @@ export class EOxMap extends LitElement { delete this.interactions[id]; }; + /** + * removes a given EOxSelectInteraction from the map. + * @param id id of the interaction + */ + removeSelect = (id: string) => { + this.selectInteractions[id].remove(); + delete this.selectInteractions[id]; + }; + /** * removes a given control from the map. * @param id id of the control element