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 |
|
Initializes a new instance of the TrafficLayer class. |
Methods
| Name | Definition | Return Value | Description |
|---|---|---|---|
|
getTileLayer |
|
Returns the traffic layer. |
|
|
hide |
|
None |
Hides the traffic layer. |
|
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>