From e65ada3c036b57cf3d5d648bcbd67be6a516107c Mon Sep 17 00:00:00 2001 From: dee077 Date: Sat, 20 Sep 2025 05:03:52 +0530 Subject: [PATCH] [feature] Allow showing moving device in geo map #443 Adds the ability to animate a node's position on the map by dynamically updating its coordinates. by adding a utility function which uses echarts.setOptions to update the node location Fixes #443 --- public/example_templates/netjsonmap.html | 2 ++ src/js/netjsongraph.util.js | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/public/example_templates/netjsonmap.html b/public/example_templates/netjsonmap.html index b88f0c94..80989548 100644 --- a/public/example_templates/netjsonmap.html +++ b/public/example_templates/netjsonmap.html @@ -137,6 +137,8 @@ document.body.appendChild(legends); map.render(); + // Todo: Romove before merge + window.map = map diff --git a/src/js/netjsongraph.util.js b/src/js/netjsongraph.util.js index 2ad84f3e..6a9487a8 100644 --- a/src/js/netjsongraph.util.js +++ b/src/js/netjsongraph.util.js @@ -1193,6 +1193,19 @@ class NetJSONGraphUtil { }, }; } + + moveNodeInRealTime(self, id, location) { + const dataIndex = series.data.findIndex(d => d.node.id === id); + const node = self.data.nodes[dataIndex] + const options = self.echarts.getOption() + const series = options.series.find(s => s.type === 'effectScatter'); + node.location = location + node.properties.location = location + series.data[dataIndex].value = [location.lng, location.lat]; + self.echarts.setOption({ + series: options.series + }); + } } export default NetJSONGraphUtil;