VEMap.AddPolyline Method

Adds a polyline (VEShape Class object of type VEShapeType Enumeration.Polyline) to the base map layer.

Syntax

VEMap.AddPolyline(points);

Parameters

Parameter Description

points

An array of VELatLong Class objects representing the points that make up the polyline. A polyline must have at least two points. Required.

Return Value

A reference to the VEShape object that was created.

Remarks

Any polyline added using this method will be added to the map's base layer. To add a polyline to a specific layer, use VEShapeLayer.AddShape Method.

Examples

<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <script src="https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>
      <script>
         var map = null;
         
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap();
         }   
         
         function DrawPoly(id,points,width,color)
         {
            poly = map.AddPolyline(points);
            poly.SetLineWidth(width);
            poly.SetLineColor(color);
            map.SetMapView(points);
         }
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
      <INPUT id="draw" type="button" 
         value="Draw a Polygon" name="drawPoly" 
         onclick="DrawPoly(
               '1', 
               [new VELatLong(46.21758,-69.08529),
                  new VELatLong(46.21531,-69.00402),
                  new VELatLong(46.21596,-68.82146),
                  new VELatLong(45.85619,-68.82360),
                  new VELatLong(45.82631,-68.82453),
                  new VELatLong(45.82633,-68.85976),
                  new VELatLong(45.81160,-68.85743),
                  new VELatLong(45.81326,-68.89499),
                  new VELatLong(45.83453,-68.94900),
                  new VELatLong(45.85566,-68.95039),
                  new VELatLong(45.85316,-69.07216),
                  new VELatLong(45.93761,-69.07287),
                  new VELatLong(45.93807,-69.08599),
                  new VELatLong(46.01658,-69.08624),
                  new VELatLong(46.01651,-69.06572),
                  new VELatLong(46.03624,-69.06471),
                  new VELatLong(46.03668,-69.08646),
                  new VELatLong(46.21758,-69.08529)],
               2,
               new VEColor(250,250,50,1.0)
               );">
      <INPUT id="drawline1" type="button" 
         value="Draw a thin blue line" name="drawLine" 
            onclick="DrawPoly(
            '2', 
            [new VELatLong(45.01188,-111.06687), 
               new VELatLong(45.01534,-104.06324),
               new VELatLong(41.01929,-104.06), 
               new VELatLong(41.003,-111.05878),
               new VELatLong(45.01188,-111.06687)],
            1,
            new VEColor(0,0,255,1));">
      <INPUT id="drawline2" type="button" 
         value="Draw a thick red line" name="drawLine2" 
            onclick="DrawPoly(
            '3', 
            [new VELatLong(45.01188,-111.06687), 
               new VELatLong(45.01534,-104.06324),
               new VELatLong(41.01929,-104.06), 
               new VELatLong(41.003,-111.05878),
               new VELatLong(45.01188,-111.06687)],
            7,
            new VEColor(255,0,0,1));">
   </body>
</html>

See Also

Reference

VEMap.AddPushpin Method
VEMap.AddPolygon Method