VEMap.AddPolygon Method

Adds a polygon (VEShape Class object of type VEShapeType Enumeration.Polygon) to the map layer.

Syntax

VEMap.AddPolygon(points);

Parameters

Parameter Description

points

The array of VELatLong Class objects representing the points that make up the polygon. A polygon must have at least three points. Required.

Return Value

A reference to the VEShape object that was created.

Remarks

Any polygon added using this method will be added to the map's base layer. To add a polygon 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;
         var pinID = 1;
         
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap();
            AddPolygon();
         }   
         
         function AddPolygon()
         {   
            var points = new Array(
              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)
              );

           map.AddPolygon(points);
           map.SetMapView(points); 
         }   
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
   </body>
</html>

See Also

Reference

VEMap.AddPolyline Method
VEMap.AddPushpin Method