VEMap.AddCustomLayer Method

You are not viewing the latest version of the AJAX control. Bing Maps AJAX V7 is the recommended JavaScript control for Bing Maps. If you need this documentation, it is available in as a CHM or PDF download.

Adds a custom layer to the map.

VEMap.AddCustomLayer(object);

Parameters

Parameter Description

object

The object to add as a layer to the map DIV container.

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title>AddCustomLayer</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>

      <script type="text/javascript">
         var map = null;
         var myLayer = null;
                  
         function GetMap()
         {  
            map = new VEMap('myMap');

            map.LoadMap();

         }
         
         // Add and remove custom layers

        
         function AddCustomLayer()
         {
            // Add a textbox to the surface of the map.
            myLayer = document.createElement('p');
            myLayer.style.position = "absolute";
            myLayer.style.top="150px";
            myLayer.style.left="200px";
            myLayer.style.width = "100px";
            myLayer.style.height = "100px";
            myLayer.style.zIndex = 2;
            myLayer.style.backgroundColor="lightblue";
            myLayer.innerHTML = "This textbox is on the map.";
            map.AddCustomLayer(myLayer);

         }


         function RemoveCustomLayer()
         {
            map.RemoveCustomLayer(myLayer);
         }


      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:600px; height:400px;"></div>
      <div id="links"><a href="#" onclick="AddCustomLayer()">Add Custom Layer</a> | <a href="#" onclick="RemoveCustomLayer()">Remove Custom Layer</a><br/></div>
   </body>
</html>

See Also

Reference

VEMap.RemoveCustomLayer Method
VEMap.AddTileLayer Method