
This Article gives a nod to three sources that made this happen:
1. Virtual Earth Tile System.
2. Chris Pietschmann’s article on VE Silverlight integration with Yahoo Maps, Open Street Maps, and Open Aerial Maps.
3. GeoWebCache Virtual Earth Examples.
To assist with configuration between GeoServer and GeoWebCache check my: configuration article.

I’m sure there’s been a significant number of downloads already at old Microsoft for their Silverlight for Virtual Earth CTP just released last Friday. Interestingly enough, ESRI released their Silverlight for ArcGIS control the day before. I’m sure I will end up using that control, as it’s off to rave reviews, but currently am focusing on Virtual Earth. The below code really wasn’t that difficult, but it is important. GeoServer, being a free and Open Source platform, with its companion GeoWebCache, are an almost undeniable combination for many server side processes. I’m loving the combination, and with REST now solidly on the back end in GeoServer 1.7.3, Look Out. This article will look specifically at the C# code, URIs, and methods necessary to pull a tiling scheme in from GeoWebCache as a custom TileSource and overlay those tiles in Silverlight for Virtual Earth.
We’re basically going to follow Pietschmann’s lead with just a few twists on the URI that GeoWebCache already uses for its Virtual Earth AJAX control.
Let’s review the general approach:
1. Create a custom TileSource object inherited from Microsoft.VirtualEarth.MapControl.TileSource.
a. Define the URI to get those images.
b. Override the GetURI method on the TileSource.
2. Add the custom TileSource to the map.
a. Add a new MapTileLayer instance to the map.
b. Create an instance of your custom TileSource object.
c. Add that TileSource to your MapTileLayer.
d. Add the MapTileLayer to the Map’s children collection.
Step 1. tasks happen in the .xaml.cs and Step 2. tasks are in the .xaml itself. There are many variations on this.
GeoWebCache has exisiting request services in place just waiting to scoop up what you’re willing to give it to get your tiles. There’s a couple of routes you can take with this:
1. the VEconverter object route which is more complex, but is informative, and potentially useful for other things.
2. the more direct Gmaps object route. VEconverter route’s C# code in xaml.cs
As you can see in the first few lines of code, GWCtileSource inherits from the VE TileSource object. This is your custom TileSource now.
In the constructor of your custom TileSource object, the :base allows us to replace our URI request with the tile(s) we are going to want to show. The request string you are looking at is a typical basic GeoServer GeoWebCache request string http://localhost:8080/geoserver/gwc/service. The ve? tells us it’s a Virtual Earth request and the topp:states is a demo layer found in GeoServer. Much of this is explained in the configuration article mentioned above. However the quadkey= part is different than the AJAX Virtual Earth client. You don’t have anything sending the right quadkey list back over to GeoWebCache to get the tiles. We, however, need to dig a little deeper with this GeoWebCache route by using the x, y, and zoom levels in a different way.
By overriding the GetUri method of the TileSource, we can grab the x tile location, y tile location and zoomlevel from this method, and push those into a Virtual Earth method to get the quadkey(s) we need. These keys are returned back to the TileSource, and we’re in business. The explanation on the TileXYToQuadKey can be found at the Microsoft source mentioned at the top of the article. Gmaps route’s C# code in xaml.cs
Your alternative approach is the above code. This was an approach I was looking in to as being more direct to the tiles, and Arne Kepp on the GeoWebCache ListServ verified it. We essentially cut out the middle man here, and use the Google Maps request string to get the tiles. On large requests, it may save you some processing overhead, but I think its important to be aware of both routes.
I’m going to move quickly through this last part as it’s easy squeezy. Here’s the xaml:
So, the XAML is doing what could also be done on the C# side of things. We’ve done it here, though. You can see we have added a MapTileLayer to the Map.Children and created an instance of the TileSource(s)GWCtileSource we declared in the C# code. The TileSource is associated with the TileLayer which is part of the map now. That’s it in a nutshell. Best of Luck.
Copyright GeoLab 2009.