Skip to content

Commit ba4f267

Browse files
committed
[fix] Updated readme, removed debugger and added some comments
1 parent 4517644 commit ba4f267

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,7 @@ NetJSON format used internally is based on [networkgraph](http://netjson.org/rfc
486486

487487
This feature allows you to create shareable and restorable map or graph states using URL fragments. When this feature is enabled, the URL updates automatically whenever you click a node or a link in your NetJSONGraph visualization. This makes it easy to share a specific view, restore it later, or navigate between different states using the browser’s back and forward buttons.
488488

489-
When you click on a node or link, information is added to the URL as a fragment (for example for node: `#map1-node=device-123` and for link: `#map1-link=deviceA~deviceB`). If you open such a URL directly in your browser, the visualization will automatically restore that exact state triggering the click event on the corresponding node or link and centering the map or graph accordingly.
490-
491-
This feature works across all ECharts graphs, as well as Leaflet-based maps including geographic and indoor floorplan maps and it supports multiple maps or graphs on the same page. The id parameter is used to uniquely identify which visualization the URL fragment belongs to (for eample: `#map1-node=device-1;#map2-node=device-2` ).
489+
This feature works across all ECharts graphs, as well as Leaflet-based maps including geographic and indoor floorplan maps and it supports multiple maps or graphs on the same page. The id parameter is used to uniquely identify which visualization the URL fragment belongs to (for example: `#map1-node=device-1;#map2-node=device-2` ).
492490

493491
For nodes, the behavior depends on the type of visualization in Leaflet maps, clicking a node updates the URL and on apllying the state from url it automatically centers the map on that node, in addition to triggering its click event. In ECharts graphs, only triggers the click event for the node.
494492

public/example_templates/netjsonmap-indoormap-overlay.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,17 @@
136136
return container;
137137
}
138138

139-
function closeButtonHandler(container) {
139+
function closeButtonHandler(container, indoorMap) {
140140
const closeBtn = container.querySelector("#indoormap-close");
141141
closeBtn.addEventListener("click", () => {
142+
const id = indoorMap.config.bookmarkableActions.id;
143+
indoorMap.utils.removeUrlFragment(id);
142144
container.remove();
143145
});
144146
}
145147

146148
function openIndoorMap() {
147149
const indoorMapContainer = createIndoorMapContainer();
148-
closeButtonHandler(indoorMapContainer);
149150
const mapContainer = document.getElementById("map-container");
150151
mapContainer.appendChild(indoorMapContainer);
151152

@@ -243,6 +244,7 @@
243244
},
244245
);
245246
indoor.render();
247+
closeButtonHandler(indoorMapContainer, indoor);
246248
}
247249
</script>
248250
</body>

src/js/netjsongraph.render.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class NetJSONGraphRender {
128128
generateGraphOption(JSONData, self) {
129129
const categories = [];
130130
const configs = self.config;
131-
const nodes = JSONData.nodes.map((node, index) => {
131+
const nodes = JSONData.nodes.map((node) => {
132132
const nodeResult = JSON.parse(JSON.stringify(node));
133133
const {nodeStyleConfig, nodeSizeConfig, nodeEmphasisConfig} =
134134
self.utils.getNodeStyle(node, configs, "graph");
@@ -584,7 +584,6 @@ class NetJSONGraphRender {
584584
const zoomOut = document.querySelector(".leaflet-control-zoom-out");
585585

586586
if (zoomIn && zoomOut) {
587-
debugger;
588587
if (Math.round(currentZoom) >= maxZoom) {
589588
zoomIn.classList.add("leaflet-disabled");
590589
} else {

src/js/netjsongraph.util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,6 @@ class NetJSONGraphUtil {
12911291
if (!self.config.bookmarkableActions.enabled) {
12921292
return;
12931293
}
1294-
debugger;
12951294
const {id} = self.config.bookmarkableActions;
12961295
const fragments = self.utils.parseUrlFragments();
12971296
const fragmentParams = fragments[id] && fragments[id].get ? fragments[id] : null;
@@ -1314,6 +1313,8 @@ class NetJSONGraphUtil {
13141313
? self.config.disableClusteringAtLevel
13151314
: self.config.bookmarkableActions.zoomLevel ||
13161315
self.config.showLabelsAtZoomLevel;
1316+
// Currently, there’s no way to center the view on a link element within the graph or map.
1317+
// The view is only centered when using a Leaflet map and the selected element is a node.
13171318
self.leaflet?.setView(center, zoom);
13181319
}
13191320
self.config.onClickElement.call(self, source && target ? "link" : "node", node);

0 commit comments

Comments
 (0)