visNetwork icon indicating copy to clipboard operation
visNetwork copied to clipboard

Feature request: display a network over a map?

Open smartinsightsfromdata opened this issue 7 years ago • 5 comments

My use case would be to be to have say a power grid (i.e. a network) displayed over a geo map.

Would this be possible?

Say over leaflet (R version of course).

I kindly invite also @bhaskarvk (of leaflet.extras fame) to give his opinion on feasibility and complexity.

smartinsightsfromdata avatar Mar 12 '17 23:03 smartinsightsfromdata

This is a two part question a) Can I overlay a network map on top of a geo map ? & b) Can I use visNetwork to overlay a network map on top of Leaflet ?

a) This is possible. You can simply use leaflet's shape overlaying methods (addMarkers, addPolylines) to do this w/o needing any other network viz, provided you have data in proper geo coordinates.

b) We haven't done a whole lot of htmlwidget intermingling. Currently it's possible for widgets to interact using crosstalk, but not co-visualize them (i.e. lay them on top of each other on a single HTML element container). But it is always possible to do this on a case by case basis.

bhaskarvk avatar Mar 13 '17 12:03 bhaskarvk

In hindsight, a "minimum viable" functionality for me would be to display my (large) graph keeping my nodes proportionally distanced on screen as they would be on a map (a node representing New York needs to be represented below & slightly to the left of the node for Boston)

My x and y coordinates are currently latitude and longitude.

@bthieurmel can I use lat long directly in visNetwork as x and y, or do I need to transform them in some way?

smartinsightsfromdata avatar Sep 09 '17 15:09 smartinsightsfromdata

Hi @smartinsightsfromdata

I'm also interested in combining simple graphs with very simple maps, and I'm very interested in doing this from R. However, I understand that this is quite difficult right now.

Would it suffice if the map was a static image, resized when the network is zoomed? If yes, I have found this vis.js issue which mentions this Fiddle. However, I'm not sure if its possible to use this by calling visEvents(beforeDrawing = "¿?") which is normally used with a single function call.

If you are not interested in this approach, I will start a new issue related to a static zoomable map.

Thank you for your attention.

benizar avatar Oct 15 '17 22:10 benizar

This is available in here https://rpubs.com/martinjhnhadley/geographic_network

But I would like to see it in visNetwork package with simple code

ncdingari avatar Jul 13 '18 17:07 ncdingari

I found the possibility to have the network as well as an image (building plan, map etc...) that adapts to the position of the network and its zoom level.

By moving the network with the mouse, the nodes will always be adapted to the image whatever its scale and the position of the network on its canvas

( For Mac Users, open with Chrome, some problems with Safari ) https://jsfiddle.net/0h3urLeo/3/

Hoping to help people looking for a solution to this problem :)

TheYakuzo avatar Oct 17 '22 13:10 TheYakuzo