Export (0) Print
Expand All

TileSourceOptions Object

Bing

Defines options for a tile source.

Properties

Name Type Description

height

number

The pixel height of each tile in the tile source. The default value is 256.

The specified height needs to be a multiplier of 2 of the current projection’s tile height for the tiles to be shown. For example, since Mercator tile source tiles are 256x256, this projection supports tiles that are 64x64, 128x128, 256x256, 512x512, or any combination of these.

uriConstructor

string

The string that constructs the URLs used to retrieve tiles from the tile source. This property is required.

The uriConstructor will replace {subdomain} and {quadkey}.

You can also set this to a callback function that receives a tile URL with location (x,y) and zoom level properties. This is useful when you want to use tiles with x/y/zoom URL structure, or if you are connecting to a Web Map Service (WMS) and need to pass the tile bounding box in the URL. For an example, see the Example section below.

width

number

The pixel width of each tile in the tile source. The default value is 256.

The specified width needs to be a multiplier of 2 of the current projection’s tile width for the tiles to be shown. For example, since Mercator tile source tiles are 256x256, this projection supports tiles that are 64x64, 128x128, 256x256, 512x512, or any combination of these.

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">
         
         function GetMap()
         {
            // Initialize the map
            var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Bing Maps Key", center:new Microsoft.Maps.Location(48.03,-122.4), zoom:12, mapTypeId: Microsoft.Maps.MapTypeId.road }); 

            try
            {
               // Create the tile layer source
               var tileSource = new Microsoft.Maps.TileSource({uriConstructor: 'http://www.microsoft.com/maps/isdk/ajax/layers/lidar/{quadkey}.png'});

               // Construct the layer using the tile source
               var tilelayer= new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: .7 });

               // Push the tile layer to the map
               map.entities.push(tilelayer);

            }
            catch(err)
            {
               alert( 'Error Message:' + err.message);
            }

         }

      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>       
   </body>
</html>


The following example shows how to use a callback function with the URI constructor.


//Create a tile layer source
var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: getTilePath });

function getTilePath(tile)
{
    //Tile Format http://tile.contoso.org/hiking/{z}/{x}/{y}.png
    return 'http://tile.contoso.com/hiking/' + tile.levelOfDetail + '/' + tile.x + '/' + tile.y + '.png';
}

See Also

Show:
© 2014 Microsoft