Algorithm Optimization - Shortest Route Between Multiple Points

后端 未结 7 1538
离开以前
离开以前 2021-02-04 11:06

Problem: I have a large collection of points. Each of these points has a list with references to other points with the distance between them already calculated and stored. I

7条回答
  •  甜味超标
    2021-02-04 11:35

    This is the very common and real time situation any one can fall in.Google map user interface gives you the path in the same order, you add in the destination list. it doesn't give you the optimal path though their own Google maps API provide the solution.

    Google maps API provides the solution for this. In the request to find out the path you have to provide the flag 'optimizeWaypoints: true,'. The request will seem like this.

    var request = {
                origin: start,
                destination: end,
                waypoints: waypts,
                optimizeWaypoints: true,
                travelMode: google.maps.TravelMode.DRIVING
            };
    

    and you can see whole code of the utility in the view source as complete utility is developed in javascript and HTML.

    I hope it will help.

提交回复
热议问题