mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
32 lines
839 B
TypeScript
32 lines
839 B
TypeScript
import { DivIcon, Map, Marker, MarkerOptions, LatLngExpression } from "leaflet";
|
|
import { SelectionEnabledChangedEvent } from "../../events";
|
|
|
|
export class CustomMarker extends Marker {
|
|
constructor(latlng: LatLngExpression, options?: MarkerOptions) {
|
|
super(latlng, options);
|
|
|
|
SelectionEnabledChangedEvent.on((enabled) => {
|
|
const el = this.getElement();
|
|
if (el === undefined || el === null) return;
|
|
if (enabled) el.classList.add("disable-pointer-events");
|
|
else el.classList.remove("disable-pointer-events");
|
|
});
|
|
}
|
|
|
|
onAdd(map: Map): this {
|
|
this.setIcon(new DivIcon()); // Default empty icon
|
|
super.onAdd(map);
|
|
this.createIcon();
|
|
return this;
|
|
}
|
|
|
|
onRemove(map: Map): this {
|
|
super.onRemove(map);
|
|
return this;
|
|
}
|
|
|
|
createIcon() {
|
|
/* Overloaded by child classes */
|
|
}
|
|
}
|