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 8:13 PM
Edited May 5, 2010 at 8:32 PM
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)
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 5:15 AM
Thanks Scott :)