Export (0) Print
Expand All

Polyline Class

Bing

Represents a polyline on the map.

Constructor

Name Definition Description

Polyline

Polyline(locations: Location[] , options?: PolylineOptions )

Initializes a new instance of the Polyline class.

Methods

Name Definition Return Value Description

getLocations

getLocations()

Location[]

Returns the locations that define the polyline.

getStrokeColor

getStrokeColor()

Color

Returns the color of the polyline.

getStrokeDashArray

getStrokeDashArray()

string

Returns the string that represents the stroke/gap sequence used to draw the polyline.

getStrokeThickness

getStrokeThickness()

number

Returns the thickness of the polyline.

getVisible

getVisible()

boolean

Returns whether the polyline is visible. A value of false indicates that the polyline is hidden, although it is still an entity on the map.

setLocations

setLocations(locations: Location[] )

None

Sets the locations that define the polyline.

setOptions

setOptions(options: PolylineOptions )

None

Sets options for the polyline.

toString

toString()

string

Converts the Polyline object to a string.

Events

Name Arguments Description

click

eventArgs:MouseEventArgs

Occurs when the mouse is used to click the polyline.

dblclick

eventArgs:MouseEventArgs

Occurs when the mouse is used to double click the polyline.

entitychanged

object: {entity:Entity}

Occurs when the location of the polyline or any of the polyline’s options change.

mousedown

eventArgs:MouseEventArgs

Occurs when the left mouse button is pressed when the mouse is over the polyline.

mouseout

eventArgs:MouseEventArgs

Occurs when the mouse cursor moves out of the area covered by the polyline.

mouseover

eventArgs:MouseEventArgs

Occurs when the mouse is over the polyline.

mouseup

eventArgs:MouseEventArgs

Occurs when the left mouse button is lifted up when the mouse is over the polyline.

rightclick

eventArgs:MouseEventArgs

Occurs when the right mouse button is used to click the polyline.

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">

          var map = null;


         function GetMap()
         {
            // Initialize the map
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Your 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(60, 20);
            var location5 = new Microsoft.Maps.Location(60, 60);


            // Create a polyline
            var lineVertices = new Array(location1, location2, location3, location4, location5);
            var line = new Microsoft.Maps.Polyline(lineVertices);

            // Add the polyline to the map
            map.entities.push(line);

         }


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