mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Started working on JTAC tools
This commit is contained in:
32
frontend/react/src/map/markers/textmarker.ts
Normal file
32
frontend/react/src/map/markers/textmarker.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { DivIcon, LatLngExpression, MarkerOptions } from "leaflet";
|
||||
import { CustomMarker } from "./custommarker";
|
||||
|
||||
export class TextMarker extends CustomMarker {
|
||||
#label: string = "";
|
||||
#backgroundColor: string = "";
|
||||
|
||||
constructor(latlng: LatLngExpression, label: string, backgroundColor: string, options?: MarkerOptions) {
|
||||
super(latlng, options);
|
||||
this.setZIndexOffset(9999);
|
||||
|
||||
this.#label = label;
|
||||
this.#backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
createIcon() {
|
||||
this.setIcon(
|
||||
new DivIcon({
|
||||
iconSize: [40, 40],
|
||||
iconAnchor: [20, 20],
|
||||
className: "leaflet-text-marker",
|
||||
})
|
||||
);
|
||||
var el = document.createElement("div");
|
||||
el.classList.add("ol-text-icon")
|
||||
el.style.backgroundColor = this.#backgroundColor;
|
||||
|
||||
this.getElement()?.appendChild(el);
|
||||
|
||||
el.innerHTML = this.#label;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user