最近的道路上Bing地图上的绘图线

时间:2014-06-27 00:31:10

标签: line bing-maps closest-points

以下代码在bing贴图上绘制一条简单的线条。有没有办法让线的起点和终点位于最近的道路上。我不想使用路由服务。如果加载时间与下面的代码一样快,那就太好了。

谢谢。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

      <script type="text/javascript">

         var map = null;
         function GetMap() {
            // Initialize the map
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Your Bing Map Credentials"}); 

            var loc1 = new Microsoft.Maps.Location(33.49753, -117.54845);
            var loc2 = new Microsoft.Maps.Location(33.993065, -117.87415);

            // Add a pin to the map
            var pin1 = new Microsoft.Maps.Pushpin(loc1); 
            var pin2 = new Microsoft.Maps.Pushpin(loc2); 


            // Create a polyline
            var lineVertices = new Array(loc1, loc2);
            var line = new Microsoft.Maps.Polyline(lineVertices);

            map.setView({center:loc2, zoom: 9} );

            map.entities.push(line);
            map.entities.push(pin1);
            map.entities.push(pin2);


         }
      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>
   </body>
</html>

0 个答案:

没有答案