none
Is there a traffic overlay for Bing maps ajax v7 control? RRS feed

  • Question

  • The subject says it all. I found the relevant information for the v6.3 but I am not seeing it for v.7.


    Thanks

    • Moved by Ricky_Brundritt Friday, March 9, 2012 5:18 PM (From:Bing Maps: Map Control and Web services Development)
    Tuesday, April 26, 2011 2:19 PM

Answers

  • For the U.S., the traffic tiles that were used in v6.3 appear to be available. You can add them as a layer to the map using code such as this:

    <!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;
         var tilelayer = null;
         function GetMap()
         {
          // Initialize the map
          map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Your Bing Maps Key", center:new Microsoft.Maps.Location(47.9,-122), zoom:9, mapTypeId:"r"}); 
    
          // Create the tile layer source
          var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: 'http://t0.tiles.virtualearth.net/tiles/t{quadkey}.png' });
    
          // Construct the layer using the tile source
          tilelayer= new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: 1.0 });
    
          // Push the tile layer to the map
          map.entities.push(tilelayer);
         }
       </script>
      </head>
      <body onload="GetMap();">
       <div id='mapDiv' style="position:relative; width:640px; height:480px;"></div>
      </body>
    </html>
    
    

    Note however that I'm not sure if these traffic tiles are still supported - since they're not really a part of the v7 API, they might be turned off at any moment, and you might want to continue investigating other sources. Also note that there are specific restriction on traffic data mentioned in the terms of use: http://www.microsoft.com/maps/product/terms.html


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by Valo Tuesday, April 26, 2011 8:12 PM
    Tuesday, April 26, 2011 6:59 PM
    Moderator

All replies

  • The Ajax v7 control does not have Traffic overlay support built in.


    Microsoft MVP - Bing Maps
    Blog: http://pietschsoft.com | Web.Maps.VE - ASP.NET AJAX Bing Maps Server Control
    Tuesday, April 26, 2011 2:32 PM
  • Do you have any suggestion of how to go about it? Are there any public tile sources that can be used to display traffic?
    Thanks
    Tuesday, April 26, 2011 2:36 PM
  • What country are you looking for? The highways agency in the UK have an RSS feed of traffic incidents reported on their website - http://www.highways.gov.uk/traffic - it's pretty easy to take data from there and create your own tile layer or shapes to put on the map.

    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Tuesday, April 26, 2011 4:59 PM
    Moderator
  • Sorry, I should've made it clear from the beginning - I need US traffic.
    Thanks
    Tuesday, April 26, 2011 5:00 PM
  • For the U.S., the traffic tiles that were used in v6.3 appear to be available. You can add them as a layer to the map using code such as this:

    <!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;
         var tilelayer = null;
         function GetMap()
         {
          // Initialize the map
          map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Your Bing Maps Key", center:new Microsoft.Maps.Location(47.9,-122), zoom:9, mapTypeId:"r"}); 
    
          // Create the tile layer source
          var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: 'http://t0.tiles.virtualearth.net/tiles/t{quadkey}.png' });
    
          // Construct the layer using the tile source
          tilelayer= new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: 1.0 });
    
          // Push the tile layer to the map
          map.entities.push(tilelayer);
         }
       </script>
      </head>
      <body onload="GetMap();">
       <div id='mapDiv' style="position:relative; width:640px; height:480px;"></div>
      </body>
    </html>
    
    

    Note however that I'm not sure if these traffic tiles are still supported - since they're not really a part of the v7 API, they might be turned off at any moment, and you might want to continue investigating other sources. Also note that there are specific restriction on traffic data mentioned in the terms of use: http://www.microsoft.com/maps/product/terms.html


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by Valo Tuesday, April 26, 2011 8:12 PM
    Tuesday, April 26, 2011 6:59 PM
    Moderator
  • Thank you!
    Thanks
    Tuesday, April 26, 2011 8:13 PM