问题描述
我正在尝试使用 vis.js 构建网络可视化并将其显示在地图上(类似于 Gephi 中的地理布局).您是否碰巧知道是否已经存在可以实现这样的目标?(如果你有建议,我什至不需要使用 vis.js)
I am trying to build a network visualization with vis.js and display it on a map (similar to Geo-layout in Gephi). Do you happen to know if something already exists to achieve such goal? (I don't even need to use vis.js if you have suggestions)
到目前为止,我尝试/考虑过使用 mapbox,但我放弃了使用真实地图的想法,因为事实证明它相当复杂.
So far I tried/thought of using mapbox but I abandoned the idea of a real map because it it turning out to be fairly complex.
我降低了对执行以下操作的期望:
I downgraded expectation to doing the following:
- 完成:在背景中有一张地图图像,并有一些我可以通过调整 x 和 y 位置手动定位的大节点
我还需要做以下事情:
- 让小节点像强制布局一样自动落到位.
问题是,如果我需要手动设置一些位置,我需要禁用物理……这当然会阻止自动定位较小的节点.
The problem is that I need to disable physics if i need to manually set some positions... this of course stops the smaller nodes from being automatically positioned.
有关如何实现这一目标的任何提示?
any hints on how to achieve this?
谢谢!
推荐答案
我完成了以下操作,在选项中设置布局和物理.(出于某种原因,改进的布局必须是错误的,这是一个幸运的猜测)
I ended doing the following, in options set the layout and physics. (for some reason, improved layout has to be false, it was a lucky guess)
layout: { improvedLayout: false }
physics: { enabled: true}
为节点设置一个名为 fixed 的属性:
For the node, set a property called fixed:
fixed: { x: true , y: true }
这里是节点的儿子:
{id: 1, value: 2, label: 'xx' , x: 320, y:170 , fixed: { x: true , y: true } }
这篇关于如何在地图上使用 vis.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!