0

The following code plots a simple line on bing maps. Is there a way that the starting and end points of the line are on a closest road. I don't want to use the routing service. It would be great if the load time is as fast it would be for the code below.

Thank you.

<!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>
RukTech
  • 5,065
  • 5
  • 22
  • 23
  • 1
    If you try to reverse-geocode the first and latest points of your path, does it retrieve a fixed location that you could use as the closest location onto a known road? – Nicolas Boonaert Jun 27 '14 at 09:06
  • Actually now I am doing something similar. Since I have over 1000 lines to draw, I am reverse geocoding the coordinates to get the closest location offline. I will then draw lines from these updated coordinates. – RukTech Jun 27 '14 at 17:51
  • Glad that this possible solution turned out to be something useful. – Nicolas Boonaert Jun 29 '14 at 15:20

0 Answers0