locked
Straight line between two points?

    Question

  • I want to plot lines between points on a map.  I am trying to create an origin and destination map and can plot my push pins ok for the origin and destination, but I need to have lines connecting the two, not route lines, just straight lines so I know 1 point is associated with another.  Haven't seen any examples of how to do this.
     
    Tuesday, August 15, 2006 2:18 PM

Answers

  • See the interactive SDK (http://dev.live.com/virtualearth/sdk/), under "Draw Lines". Basically, you just create a VEPolyline (http://msdn.microsoft.com/library/en-us/VEMapControl/HTML/C_Namespace_VEPolyline_ctor.asp?frame=true) and specify the start and end points. Very easy!

     

    Here's a complete code snippet that draws a straight red line across the top of Wyoming:

     

    <html>
       <head>
          <title></title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
          <script src="
    http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
          <script>
             var map = null;
            
             function GetMap()
             {
                map = new VEMap('myMap');
                map.LoadMap();
             }  
            
             function DrawPoly(id,points,width,color)
             {
                poly = new VEPolyline(id,points);
                poly.SetWidth(width);
                poly.SetColor(color);
                map.AddPolyline(poly);
             }
          </script>
       </head>
       <body onload="GetMap();">
          <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
          <INPUT id="draw" type="button" value="Draw a Line" onclick="DrawPoly(
                   '1',
                   [new VELatLong(45.01188,-111.06687),
                   new VELatLong(45.01534,-104.06324)],
                   2,
                   new VEColor(255,0,0,1)
                   );">
       </body>
    </html>

    Tuesday, August 15, 2006 2:27 PM

All replies

  • See the interactive SDK (http://dev.live.com/virtualearth/sdk/), under "Draw Lines". Basically, you just create a VEPolyline (http://msdn.microsoft.com/library/en-us/VEMapControl/HTML/C_Namespace_VEPolyline_ctor.asp?frame=true) and specify the start and end points. Very easy!

     

    Here's a complete code snippet that draws a straight red line across the top of Wyoming:

     

    <html>
       <head>
          <title></title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
          <script src="
    http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
          <script>
             var map = null;
            
             function GetMap()
             {
                map = new VEMap('myMap');
                map.LoadMap();
             }  
            
             function DrawPoly(id,points,width,color)
             {
                poly = new VEPolyline(id,points);
                poly.SetWidth(width);
                poly.SetColor(color);
                map.AddPolyline(poly);
             }
          </script>
       </head>
       <body onload="GetMap();">
          <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
          <INPUT id="draw" type="button" value="Draw a Line" onclick="DrawPoly(
                   '1',
                   [new VELatLong(45.01188,-111.06687),
                   new VELatLong(45.01534,-104.06324)],
                   2,
                   new VEColor(255,0,0,1)
                   );">
       </body>
    </html>

    Tuesday, August 15, 2006 2:27 PM
  • Awesome, thanks!
    Tuesday, August 15, 2006 4:15 PM
  •  

    is there a way to draw lines between points in aspx.vb code?
    Thursday, September 18, 2008 8:46 PM
  •  

    This does it in c#

     

    Shape MyDash = new Shape(ShapeType.Polyline, thePoints);

     

    thePoints would be where you send your latitude and longitude.

    i am sure it will not be hard to convert this to vb

    Friday, September 19, 2008 4:43 PM