This topic has not yet been rated - Rate this topic

VEShape.GetZIndex Method

Bing Services

Gets the z-index of a pushpin shape or pushpin attached to a polyline or polygon.


VEShape.GetZIndex();

An integer containing the z-index of the pushpin shape or pushpin attached to a polyline or polygon. Use the VEShape.GetZIndexPolyShape Method to get the z-indices for a polyline or polygon.

<!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=6.3"></script>

      <script type="text/javascript">
         var map = null;
         var myShape = null;  // For polygon
         var myPin   = null;  // For pushpin

         var Red   = new VEColor(255,   0,   0, 1.0);

         var topLeft  = new VELatLong(45.5, -116.5);
         var topRight = new VELatLong(45.5, -106.5);
         var botRight = new VELatLong(35.5, -106.5);
         var botLeft  = new VELatLong(35.5, -116.5);

         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap();

            // Add red polygon
            myShape = new VEShape(VEShapeType.Polygon, new Array(topLeft, topRight, botRight, botLeft));
            myShape.HideIcon();
            myShape.SetFillColor(Red);

            map.AddShape(myShape);

            // Pushpin starts on top as its default zindex is 1000 while polygon is 50
            myPin = new VEShape(VEShapeType.Pushpin, new VELatLong(40.5, -111.5));

            map.AddShape(myPin);
         }

         function Switch()
         {
            // Move the polygon in front
            myShape.SetZIndex(null, myPin.GetZIndex() + 1);

            btnswitch.disabled = "disabled";
         }
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:600px; height:400px;"></div>
      <p>&nbsp;</p>
      <input id="btnswitch" type="button" value="Move Polygon to Front" name="switch" onclick="Switch();">
   </body>
</html>

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.