GMap.NET and VB : How to get the shortest Route between points ? RRS feed

  • Question

  • Hi everybody,

    a question about GMap.NET library in VB .NET language.

    This is what I do to display on Map ( GMapControl on a Form in a Windows Forms Application ) a simple route with just 2 points : P1 is Start and P2 is Destination.

    The working code is :

            GMC.Position = New PointLatLng(40.654331, -73.917067)
            Dim RP As RoutingProvider = DirectCast(GMC.MapProvider, RoutingProvider)
            Dim P1 As New PointLatLng(40.657161, -73.921079)
            Dim P2 As New PointLatLng(40.65587, -73.915188)
            Dim MP As MapRoute = RP.GetRoute(P1, P2, True, False, Convert.ToInt32(GMC.Zoom))
            Dim R As New GMap.NET.WindowsForms.GMapRoute(MP.Points, "Route")
            Dim SB As New SolidBrush(Color.FromArgb(125, 0, 255, 0))
            R.Stroke = New Pen(SB, 6)

    Where GMC is my GMapControl,

    and mOverlayRoutes is a simple GMap.NET.WindowsForms.GMapOverlay previously declared and added to GMC.Overlays :

      mOverlayRoutes = New GMap.NET.WindowsForms.GMapOverlay("Routes")

    Code is very simple and works well.

    Now the question is : How to get the same route with 3 or more Points ?

    For Example, I have now 5 Points and my route has to be the shortest possible, reaching all 5 Points on the map.

    Has someone here solved the same kind of problem ?

    Thanks to everyone able to help.

    Wednesday, July 18, 2018 3:14 PM

All replies

  • Hi

    You are delving into the non-trivial Traveling Salesman problem.

    If you Google that (or, Kookaburra algorithm), you will get a lot of information.

    I don't know anything of GMap.NET, it may contain methods to do such a thing, but since it is an extremely complex and time consuming task, I would doubt that it does.

    Small numbers of cities could probably be handled reasonably quickly.

    Regards Les, Livingston, Scotland

    Wednesday, July 18, 2018 4:09 PM
  • Yes, I see.

    Thanks for attention, I'm searching.

    Let's see if someone here can suggest a possible use in a .NET project... 

    Thursday, July 19, 2018 7:39 AM
  • Yes, I see.

    Thanks for attention, I'm searching.

    Let's see if someone here can suggest a possible use in a .NET project... 

    Have you searched these forums for keywords like "shortest route between points" and "traveling salesman problem"?  I know this has been discussed in the past and as a non-trivial problem to solve (which is only reasonably "solvable" with a small number of points) the code can get long and complex in a hurry.  I would not hold your breath waiting for new examples...  You should find existing examples and then use them as a basis for your own solution, working within the confines of your specific problem.  You'll need to think of ways to limit the requirements as much as possible to suit your particular needs as closely as you can, knowing that an ideal solution probably doesn't exist.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Thursday, July 19, 2018 12:54 PM
  • Thank you for your message.

    I assure you I'm already working on my solution and I'm not "holding my breath".

    If there is a single chance someone here has solved the same problem, using GMap.NET, and could share the experience, I would be glad to read how, that's all.

    Thanks again. 

    Thursday, July 19, 2018 1:08 PM
  • Hi

    Do you resolve the issue?If you resolve the issue, could you please mark the helpful as answer. it will be beneficial to other community.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, August 3, 2018 5:49 AM