Skip to content

Commit

Permalink
fix: Marker tooltips should hide when a layer is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Dec 1, 2023
1 parent c80da47 commit 19d5765
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/layer/marker.ts
Expand Up @@ -204,7 +204,9 @@ export class Marker extends Layer<DivIconMarker> {
) {
super();

const markerIcon = this.map.markerIcons.get(type) ?? this.map.markerIcons.get('default');
const markerIcon =
this.map.markerIcons.get(type) ??
this.map.markerIcons.get("default");
if (!markerIcon) {
new Notice(
t(
Expand Down Expand Up @@ -410,6 +412,17 @@ export class Marker extends Layer<DivIconMarker> {
this.leafletInstance.options.keyboard = !this.map.options.lock;
});
});

this.map.leafletInstance.on(
"baselayerchange",
(layer: L.LayersControlEvent) => {
if (!(layer.layer as L.LayerGroup).hasLayer(this.group)) {
this.hide();
} else {
this.show();
}
}
);
}
editMarker() {
let markerSettingsModal = new MarkerContextModal(this, this.map);
Expand Down Expand Up @@ -483,9 +496,7 @@ export class Marker extends Layer<DivIconMarker> {
);
}
}
this._link = x.startsWith("#")
? this.map.options.context + x
: x;
this._link = x.startsWith("#") ? this.map.options.context + x : x;
if (this.target) this.target.text = x;
if (this.popup && this.displayed && this.tooltip === "always")
this.popup.open(this.target.display);
Expand Down

0 comments on commit 19d5765

Please sign in to comment.