Tiled WMS overlay in Windows Phone 7


  Update 13/03/2013, here is new  blog about Tiled WMS overlay for Windows Phone 8 :https://blog.sumbera.com/2013/03/10/tiled-wms-overlay-in-windows-phone-8/

This post [https://blog.sumbera.com/2010/02/25/overlay-wms-on- google-in-silverlight-bing/ ] talked about how to overlay over the Bing maps Silverlight control Google tiles  and tiled WMS. It was quite easy to port this web sample into the Windows Phone 7 emulator. I took a smaple code from Training kit called “Ex1-TheBingMapControl” and extend it with the 2 classes : GoogleTile and WmsTile, with slight changes to the namespace using Microsoft.Phone.Controls.Maps (original for Silverlight was  Microsoft.Maps.MapControl). Then extend MainPage.XAML with :

                    <my:MapTileLayer Opacity=”1″>
                    <my:MapTileLayer Opacity=”1″>

Extended sample code availabel for download here : http://www.sumbera.com/lab/wp7/TheBingMapControlWithWMSandGoogle.zip

Update: I found the way calculating BoundingBox from the quadkey somehow limiting (the DeepEarth weay) since it worked only till the level 18. So here is updated class fro getting correct bounding box of the tiled WMS request in the Bing Silverlight control:

            public static double TileToWorldPosX(double tile_x, int zoom) {
return  (float)((tile_x / Math.Pow(2.0, zoom) * 360.0) – 180.0);
public static double TileToWorldPosY( double tile_y, int zoom) {
double n = Math.PI – ((2.0 * Math.PI * tile_y) / Math.Pow(2.0, zoom));
return   (float)(180.0 / Math.PI * Math.Atan(Math.Sinh(n)));
public override Uri GetUri(int tilePositionX, int tilePositionY, int tileLevel) {
                int zoom = tileLevel; //SSU tileLevel would be same as zoom in Bing control
double deltaX = 0;// 0.00135; //SSU deltaX for SLP WMS
double deltaY = 0;// 0.00058; //SSU deltaY for SLP WMS
double minXLon = TileToWorldPosX(tilePositionX, zoom) + deltaX;
double minYLat = TileToWorldPosY(tilePositionY + 1, zoom) + deltaY;
double maxXLon = TileToWorldPosX(tilePositionX + 1, zoom) + deltaX;
double maxYLat = TileToWorldPosY(tilePositionY, zoom) + deltaY;
string wmsUrl = string.Format(this.UriFormat, minXLon, minYLat, maxXLon, maxYLat, 256);
return new Uri(wmsUrl);


This entry was posted in Code, Windows Phone 7, WMS and tagged , , , , . Bookmark the permalink.

2 Responses to Tiled WMS overlay in Windows Phone 7

  1. Pingback: Overlay WMS on Google in Silverlight Bing « Geospatial Haiku

  2. Pingback: Tiled WMS overlay in Windows Phone 8 | Geospatial Haiku

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s