Export (0) Print
Expand All

PolygonOptions Object

Bing

Represents the options for a polygon.

Properties

Name Type Description

fillColor

Color

The color of the inside of the polygon.

infobox

Infobox

The info box associated with this polygon. If an info box is assigned and the Microsoft.Maps.Themes.BingTheme module is loaded, then the info box appears when the hover or click events of the polygon occur.

strokeColor

Color

The color of the outline of the polygon.

strokeDashArray

string

A string representing the stroke/gap sequence to use to draw the outline of the polygon. The string must be in the format S, G, S*, G*, where S represents the stroke length and G represents gap length. Stroke lengths and gap lengths can be separated by commas or spaces. For example, a stroke dash string of “1 4 2 1” would draw the polygon outline with a dash, four spaces, two dashes, one space, and then repeated.

strokeThickness

number

The thickness of the outline of the polygon.

visible

boolean

A boolean indicating whether to show or hide the polygon. A value of false indicates that the polygon is hidden, although it is still an entity on the map.

Example

<!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">
         
         function GetMap()
         {
            // Initialize the map
            var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),
{credentials:"Bing Maps Key"}); 

            // Create the locations
            var location1 = new Microsoft.Maps.Location(20,-20);
            var location2 = new Microsoft.Maps.Location(20,20);
            var location3 = new Microsoft.Maps.Location(-20,20);
            var location4 = new Microsoft.Maps.Location(-20,-20);


            // Create a polygon 
            var vertices = new Array(location1, location2, location3, location4, location1);
            var polygon = new Microsoft.Maps.Polygon(vertices,
                              {fillColor: new Microsoft.Maps.Color(100,100,0,100), 
                               strokeColor: new Microsoft.Maps.Color(200,0,100,100),
                               strokeThickness: 5});

            
            // Add the shape to the map
            map.entities.push(polygon)

            // Set the view
            map.setView({bounds: Microsoft.Maps.LocationRect.fromLocations(vertices)});

         }


      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>       
   </body>
</html>
Show:
© 2015 Microsoft