4 out of 5 rated this helpful - Rate this topic

TrafficLayer Class (deprecated)

Bing Services

This class is deprecated. Use the TrafficManager Class.

Represents a traffic layer on the map.

Constructor

Name Definition Description

TrafficLayer

TrafficLayer(map: Map )

Initializes a new instance of the TrafficLayer class.

Methods

Name Definition Return Value Description

getTileLayer

getTileLayer()

TileLayer

Returns the traffic layer.

hide

hide()

None

Hides the traffic layer.

show

show()

None

Displays the traffic layer.

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()
      {  

         map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "Bing Maps Key", center: new Microsoft.Maps.Location(47.5, -122.3), zoom: 9 });

         Microsoft.Maps.loadModule('Microsoft.Maps.Traffic', { callback: trafficModuleLoaded });

      }


      function trafficModuleLoaded()
      {
         var trafficLayer = new Microsoft.Maps.Traffic.TrafficLayer(map);
         trafficLayer.show();
      }
     

      
      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:600px; height:600px;"></div> 
   </body>
</html>
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.