Skip to content

Commit a4054d7

Browse files
committed
[Fix] Resolve redundant node labels and overlays #454
Updated mapRender to hide emphasis labels on hover to prevent overlap with overlays. Ensures labels do not overlap with other map elements when hovering. Fixes #454
1 parent 69cf085 commit a4054d7

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/js/netjsongraph.render.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,22 @@ class NetJSONGraphRender {
535535
}
536536
}
537537

538-
if (self.leaflet.getZoom() < self.config.showLabelsAtZoomLevel) {
538+
// 4. Resolve label visibility threshold
539+
let {showMapLabelsAtZoom} = self.config;
540+
if (showMapLabelsAtZoom === undefined) {
541+
if (self.config.showLabelsAtZoomLevel !== undefined) {
542+
showMapLabelsAtZoom = self.config.showLabelsAtZoomLevel;
543+
} else {
544+
showMapLabelsAtZoom = 13;
545+
}
546+
}
547+
548+
const currentZoom = self.leaflet.getZoom();
549+
const showLabel =
550+
typeof showMapLabelsAtZoom === "number" &&
551+
currentZoom >= showMapLabelsAtZoom;
552+
553+
if (!showLabel) {
539554
self.echarts.setOption({
540555
series: [
541556
{
@@ -554,18 +569,18 @@ class NetJSONGraphRender {
554569
}
555570

556571
self.leaflet.on("zoomend", () => {
557-
const currentZoom = self.leaflet.getZoom();
558-
const showLabel = currentZoom >= self.config.showLabelsAtZoomLevel;
572+
const cZoom = self.leaflet.getZoom();
573+
const sLabel = cZoom >= self.config.showLabelsAtZoomLevel;
559574
self.echarts.setOption({
560575
series: [
561576
{
562577
id: "geo-map",
563578
label: {
564-
show: showLabel,
579+
show: sLabel,
565580
},
566581
emphasis: {
567582
label: {
568-
show: showLabel,
583+
show: false,
569584
},
570585
},
571586
},
@@ -580,13 +595,13 @@ class NetJSONGraphRender {
580595
const zoomOut = document.querySelector(".leaflet-control-zoom-out");
581596

582597
if (zoomIn && zoomOut) {
583-
if (Math.round(currentZoom) >= maxZoom) {
598+
if (Math.round(cZoom) >= maxZoom) {
584599
zoomIn.classList.add("leaflet-disabled");
585600
} else {
586601
zoomIn.classList.remove("leaflet-disabled");
587602
}
588603

589-
if (Math.round(currentZoom) <= minZoom) {
604+
if (Math.round(cZoom) <= minZoom) {
590605
zoomOut.classList.add("leaflet-disabled");
591606
} else {
592607
zoomOut.classList.remove("leaflet-disabled");
@@ -676,8 +691,8 @@ class NetJSONGraphRender {
676691
params.data.cluster
677692
) {
678693
// Zoom into the clicked cluster instead of expanding it
679-
const currentZoom = self.leaflet.getZoom();
680-
const targetZoom = Math.min(currentZoom + 2, self.leaflet.getMaxZoom());
694+
const NewZoom = self.leaflet.getZoom();
695+
const targetZoom = Math.min(NewZoom + 2, self.leaflet.getMaxZoom());
681696
self.leaflet.setView(
682697
[params.data.value[1], params.data.value[0]],
683698
targetZoom,

0 commit comments

Comments
 (0)