2014-09-03 161 views

回答

0

沒有人回答這個問題。最後我得到了我自己的解決方案:D

讓我告訴你!在創建方向服務的同時,所有邊界將被存儲在「路徑」中。所以使用這個數組。然後使用幾何函數「isLocationOnEdge」your_point,poly-lines數組,它會返回true或false(就是這樣:D)不要忘記添加度.. ..默認度是10e-10,所以把它改成10e-2或者什麼的。

 var request = { 
     origin: document.getElementById("from").value, 
     destination: document.getElementById("to").value, 
     travelMode: google.maps.DirectionsTravelMode.DRIVING 
     } 

     // Make the directions request 

     directionService.route(request, function(result, status) { 

     if (status == google.maps.DirectionsStatus.OK) { 
      directionsRenderer.setDirections(result); 

      // Box around the overview path of the first route 
      var path = result.routes[0].overview_path; 


      var my_polyline = new google.maps.Polyline({ 
     path: path, 
     geodesic: true, 
     strokeColor: '#black', 
     strokeOpacity: 1.0, 
     strokeWeight: 2 
     }); 

     my_polyline.setMap(map); 



    var my_position=new google.maps.LatLng(12.9860932,80.1744085); 


    console.log(google.maps.geometry.poly.isLocationOnEdge(my_position, my_polyline)); 


     var boxes = routeBoxer.box(path, distance); 
     // alert(boxes.length); 


    } else { 
     alert("Directions query failed: " + status); 
    } 
    }); 
0

使用旅行銷售人員算法找到最短路徑。該算法表明,銷售人員如何在所有其他路線中以總行駛距離等於最小距離行駛所有不同地點。

+0

你能解釋一下它咬 – 2014-09-03 13:08:16

+0

http://dspace.mit.edu/bitstream/handle/1721.1/46828/algorithmfortrav00litt.pdf通過這個PDF文件。你一定會得到你的答案。 – 2014-09-04 17:59:51

+0

任何人都知道路線拳擊手 – 2014-09-05 12:16:56