This project has moved and is read-only. For the latest updates, please go here.

Using Bing Maps with TileLayer

Topics: SharpMap Project
May 4, 2010 at 11:23 PM

I'm trying to use an online map service to provide a background for various shapefiles I want to render out.  Using the OSM provider is easy:

SharpMap.Layers.TileLayer tileLayer = new SharpMap.Layers.TileLayer( new BruTile.Web.OsmTileSource(), "OSM");


Now I'm trying to determine how to hook up Bing.  I see that there's a BingTileSource, however I don't know what the url and token parameters are or how to supply them correctly.

SharpMap.Layers.TileLayer tileLayer = new BruTile.Web.BingTileSource("url", "token", BruTile.Web.MapType.Hybrid), "BING");

After digging around in the "Bing Map Account Center",  I see there's a "Create or view Bing Maps keys"  which lets you provide a url and generates a 'key'.  Using this url and key for the constructor of the above object only results in '(404) Not Found' printed all over my image.

Does anyone have experience on how to hook this up?



May 5, 2010 at 9:13 PM
Edited May 5, 2010 at 9:32 PM
Hi Nick,


Dim tileSource As BruTile.Web.BingTileSource
Dim tileLayer As SharpMap.Layers.TileLayer
Dim token as String
Dim layerName as String

token = "xxxxxx" 'token obtained from microsoft
layerName = "Bing roads layer"
tileSource = New BruTile.Web.BingTileSource(BruTile.Web.BingRequest.UrlBing, token, BruTile.Web.MapType.Roads)
tileLayer = New SharpMap.Layers.TileLayer(tileSource, layerName)

BruTile.Web.BingTileSource tileSource;
SharpMap.Layers.TileLayer tileLayer;
String token;
String layerName;

token = "xxxxxx"; //token obtained from microsoft
layerName = "Bing roads layer";
tileSource = new BruTile.Web.BingTileSource(BruTile.Web.BingRequest.UrlBing, token, BruTile.Web.MapType.Roads);
tileLayer = new SharpMap.Layers.TileLayer(tileSource, layerName);

Change BruTile.Web.MapType to get different map types (roads, hybrid, aerial). You can also use BruTile.Web.BingRequest.UrlBingStaging which does not require a token.


May 6, 2010 at 6:15 AM

Thanks Scott :)