Skip to content

Commit 19d5765

Browse files
committed
fix: Marker tooltips should hide when a layer is changed
1 parent c80da47 commit 19d5765

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/layer/marker.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ export class Marker extends Layer<DivIconMarker> {
204204
) {
205205
super();
206206

207-
const markerIcon = this.map.markerIcons.get(type) ?? this.map.markerIcons.get('default');
207+
const markerIcon =
208+
this.map.markerIcons.get(type) ??
209+
this.map.markerIcons.get("default");
208210
if (!markerIcon) {
209211
new Notice(
210212
t(
@@ -410,6 +412,17 @@ export class Marker extends Layer<DivIconMarker> {
410412
this.leafletInstance.options.keyboard = !this.map.options.lock;
411413
});
412414
});
415+
416+
this.map.leafletInstance.on(
417+
"baselayerchange",
418+
(layer: L.LayersControlEvent) => {
419+
if (!(layer.layer as L.LayerGroup).hasLayer(this.group)) {
420+
this.hide();
421+
} else {
422+
this.show();
423+
}
424+
}
425+
);
413426
}
414427
editMarker() {
415428
let markerSettingsModal = new MarkerContextModal(this, this.map);
@@ -483,9 +496,7 @@ export class Marker extends Layer<DivIconMarker> {
483496
);
484497
}
485498
}
486-
this._link = x.startsWith("#")
487-
? this.map.options.context + x
488-
: x;
499+
this._link = x.startsWith("#") ? this.map.options.context + x : x;
489500
if (this.target) this.target.text = x;
490501
if (this.popup && this.displayed && this.tooltip === "always")
491502
this.popup.open(this.target.display);

0 commit comments

Comments
 (0)