Recent Blog Posts RSS
ViaWindowsLive on Via Virtual Earth Blog
The new ViaWindowsLive community site has launched and features not only a definitive set of resources on all Live Services from Microsoft but also a special section on Virtual Earth including a new site gallery for you to upload your sites, new articles on Version 6, including getting started guide, an interactive quick guide, location finder and more. Subscribe to the VWL aggregated blog to stay in touch with everything Live Services related. Find all the great content from this site and much, much more. Explore how other Live Services can compliment Virtual Earth and your applications.
Version 5 URL changed - Error: 'VEMap' is undefined on Via Virtual Earth Blog
It has been reported that the old url to access the Version5 javascript for Virtual Earth no longer works. This is effecting sites worldwide.
The correct way to reference the Version 5 javascript is:
<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>
If you have been effected a forum thread has been started here
Silverlight Virtual Earth viewer on Via Virtual Earth Blog
With the launch of silverlight yesterday I was digging around and found this viewer for Virtual Earth by Greg Schechter. It does use the 1.1 alpha of silverlight. It gives some interesting ideas for where Virtual Earth could be headed. Certainly the demo of the performance of silverlight compared to javascript for processing showed a significant increase. This could be very useful.
And of course on the gamer front check this out by Andy Beaulieu and shoot down some UFO's over Birdseye images.
John.
So much new Virtual Earth Imagery Worldwide. on Via Virtual Earth Blog
I subscribe to all the VE blogs and recently the posts about updated imagery has been more and more frequent.
The latest is here and for myself downunder we saw three updates, Canberra, Newcastle and Uluru:


Derek Chan posts 3 Articles in a month! on Via Virtual Earth Blog
A big thank you to the efforts of Derek Chan who posted his third VE article today (he actually had it ready weeks ago but had to wait for Mr Bottleneck here at VVE ;) )
The 3 articles are all relivant to Version 5 of Virtual Earth and deal with the Mini Map, debugging javascript and now custom pins in routes.
All these can now be found in our articles section.
If you have something to contribute send us an email.
John (The bottleneck)
Accessing WMS from Virtual Earth RSS
The Web Mapping Server (WMS) protocol was developed by the Open Geospatial Consortium (OGC) as a standard for accessing maps over the Web. WMS has been widely adopted within the Geographical Information Systems (GIS) community and there is a wealth of information available in WMS format on the Web. A catalogue of sites is available at http://wms-sites.com/.
Microsoft Virtual Earth provides the ability to overlay your own maps and charts using MapCruncher and custom tile servers but does not yet support WMS directly. This article explains how to build a gateway that allows you to include WMS in your Virtual Earth mash-ups.
Recap: Virtual Earth Servers
The Microsoft Virtual Earth servers deliver map tiles based on a quad tree algorithm which splits the world up into 256 x 256 squares at zoom levels 1 to 19. For more information see �Roll Your Own Tile Server� at �http://viavirtualearth.com/vve/Articles/RollYourOwnTileServer.ashx
Web Map Servers
Web Map Servers provide a REST interface to enable access to bitmap images of maps.
Here is a typical request:
As you can see the URL consists of a number of options and settings. We're primarily interested in WIDTH and HEIGHT which specify the size of the bitmap and the BBOX which specifies the map extents.
The full WMS protocol is described in a document called �OpenGIS� Web Map Service (WMS) Implementation Specification� available from the OGC web site at http://www.opengeospatial.org/standards/wms
Virtual Earth uses a WGS84 Mercator projection, but WMS servers need you to specify the projection. In this case we�ve specified a Coordinate Reference System (CRS) of EPSG:4326 which is a common geographic projection that is equivalent �to WGS84.
The WMS standard has a wide range of other features that we won�t consider here, including the ability to ask a server for its capabilities.
Building the Glue
To allow access to WMS, we need to find a way of converting Virtual Earth style tile requests into WMS requests and create the Virtual Earth tiles on-the-fly. Sounds complicated, but in fact most of the hard work is already done and described in the �Roll Your Own Tile Server� article at http://viavirtualearth.com/vve/Articles/RollYourOwnTileServer.ashx . We can take that code sample as a template for this project.
We just need to set up an HTTP handler to intercept Virtual Earth Tile requests and fulfil them with information from WMS � essentially a kind of proxy server.
Algorithm
The algorithm is as follows:
For each tile request...
Find the quad key from the URL and use this to determine a bounding box of coordinates in WGS84 latitude and longitude.
Build a request to the WMS server using this bounding box and specifying a bitmap size of 256x256. Make the request using an HTTP GET.
Return the resultant WMS bitmap as if it were a Virtual Earth Tile.
Code
The resultant code looks like this:
public void ProcessRequest(HttpContext context)
{
// Extract the QuadKey from the URL
string urlString = context.Request.Url.ToString();
string quadKey = GetQuadKey(urlString);
int zoomLevel = quadKey.Length;
// Use the quadkey to determine a bounding box for the requested tile
Box boundingBox = QuadKeyToBox(quadKey);
// Get the lat longs of the corners of the box
double lon = XToLongitudeAtZoom(boundingBox.x * TILE_SIZE, 18);
double lat = YToLatitudeAtZoom(boundingBox.y * TILE_SIZE, 18);
double lon2 = XToLongitudeAtZoom((boundingBox.x + boundingBox.width) * 256, 18) ;
double lat2 = YToLatitudeAtZoom((boundingBox.y - boundingBox.height) * 256, 18);
string url = string.Format(
"http://www.mapsherpa.com/cgi-bin/wms_iodra?LAYERS=Bathymetry&FORMAT=image%2Fgif
&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.
ogc.se_inimage&SRS=EPSG%3A4326&BBOX={0}&WIDTH=256&HEIGHT=256",
string.Format("{0},{1},{2},{3}", lon, lat, lon2, lat2));
Bitmap wmsBitmap = DownloadImage(url);
Bitmap tileBitmap = new Bitmap(TILE_SIZE, TILE_SIZE);
Graphics graphics = Graphics.FromImage(tileBitmap);
graphics.DrawImage(wmsBitmap, 0, 0, TILE_SIZE, TILE_SIZE);
graphics.Dispose();
// Stream the image out in respnse to the HTTP request
MemoryStream streamImage = new MemoryStream();
tileBitmap.Save(streamImage, ImageFormat.Png);
context.Response.Clear();
context.Response.ContentType = "image/png";
context.Response.AddHeader("content-length",
System.Convert.ToString(streamImage.Length));
context.Response.BinaryWrite(streamImage.ToArray());
// Clean up
tileBitmap.Dispose();
streamImage.Dispose();
wmsBitmap.Dispose();
}
Just replace the URL line with details of the WMS server you want to access.
Source Code
You can download the source here
Example
I attach a working example of the code with a simple web page and Virtual Earth control that can be used as a test.
The amazing thing is that this all works in 3D without adding any extra code:

(Bathymetry courtesy of www.mapsherpa.com)
References
[1] http://wms-sites.com/ A catalog of WMS sites.
[2] Roll Your Own Tile Server, http://viavirtualearth.com/vve/Articles/RollYourOwnTileServer.ashx
[3] OpenGIS� Web Map Service (WMS) Implementation Specification, http://www.opengeospatial.org/standards/wms
Rob Blackwell
Rob Blackwell is a director at Active Web Solutions Ltd (www.aws.net), a Microsoft Partner that specialises in Virtual Earth and Web GIS solutions in the UK and Europe.
Email rob.blackwell@aws.net� Blog: www.robblackwell.org.uk
Have you got something to contribute?


