Advance Polygon shapes in Virtual Earth

Virtual Earth currently supports polygons that consist of a single array of points. Many geospatial systems have complex polygons which may consist of several arrays of points which are a combination of outer and inner arrays of points. These are often referred to as Multipolygons. Multipolygons are often used to represent complex boundary areas such as "donut" shaped polygons. By properly concatenating inner and outer polygon array segments in the proper order a single array can be created to represent a complex polygon. An array of polylines can then be created to represent the edges of the polygon. The following method takes in an array of inner and outer polygon array segments and returns and an array of shapes. This array consists of a polygon and and several polylines. This array of shapes can then be added to the map either by looping through each shape and adding it to the map, or by passing the array through the MultiShape class described here:!E7DBA9A4BFD458C5!605.entry

The MultiShape class will give you greater control of the complex polygon. 

function CreateAdvancePolygon(polyPoints)
    if(polyPoints.length > 0)
        var anchor = polyPoints[0][0];
        var points = polyPoints[0].concat(anchor);
        var lines = new Array();
        var line = new VEShape(VEShapeType.Polyline,points);
        for(var i=1;i<polyPoints.length;i++)
            points = points.concat(polyPoints[i],polyPoints[i][0],anchor);
            var line = new VEShape(VEShapeType.Polyline,polyPoints[i].concat(polyPoints[i][0]));
        var polygon = new VEShape(VEShapeType.Polygon, points);
        polygon.SetLineColor(new VEColor(0,0,0,0));
        return lines.concat(polygon);
    return null;


Below is an example of a complex polygon that was created using the above method. Complete sample code for this polygon can be found here:


3 thoughts on “Advance Polygon shapes in Virtual Earth

  1. Pingback: “Advanced Shapes” (i.e. Donut Polygons) on Bing Maps | Alastair Aitchison

  2. Pingback: Complex Polygons in Bing Maps - Ricky's Bing Maps Blog - Site Home - MSDN Blogs

  3. Pingback: Complex Polygons in Bing Maps | Cicor Marketing | Tampa Chicago

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s