I agree with this blog “Learning how to use Maps in the .Net world is a never ending business. There are major API-differences between WPF, Silverlight, Windows 8 Store apps and Windows Phone and even between WP7 and WP8. Windows Phone 8.1 makes no differ and there are many breaking changes here”
my tests of previous WMS overlays are listed here:
Silverlight : https://blog.sumbera.com/2010/02/25/overlay-wms-on-silverlight-bing/
Windows Phone 7: https://blog.sumbera.com/2011/02/18/windows-phone-7-wms-test/
Windows Phone 8: https://blog.sumbera.com/2013/03/10/tiled-wms-overlay-in-windows-phone-8/
I have put together Visual studio 2013, Update2 Solution that does WMS overlay in Windows 8.1 and Windows Phone 8.1 called WMSonWin81 – here on github
Video of Windows Phone 8.1 below, used “Project My Screen App” to project the app on desktop and record.
WMSonWin81
WMSonWin81using universal app for Windows Store and Windows Phone Store apps Both apps do not share same namespace for map nor component. Windows Store is using Bing Map while Windows Phone is using map control as part of the WP8.1 framework located in Windows.UI.Xaml.Controls.Maps
there are main 2 projects:
WMSOnWin.Windows
Sample code of using WMS source on Windows Store Apps using Bing Maps:
MapTileLayer mapTileLayer = new MapTileLayer(); mapTileLayer.GetTileUri += delegate(object sender, GetTileUriEventArgs e) { Rect mercBounds = GlobalMercator.TileBounds(new Tile(e.X, e.Y), e.LevelOfDetail); e.Uri = new Uri(string.Format(_wmsUrl, mercBounds.Left, Math.Abs(mercBounds.Bottom), mercBounds.Right, Math.Abs(mercBounds.Top))); };
_bingMap.TileLayers.Add(mapTileLayer);
WMSOnWin.WindowsPhone
Sample code of using WMS on Windows Phone Store App using Windows.UI.Xaml.Controls.Maps; core class to look is HttpMapTileDataSource
HttpMapTileDataSource dataSource = new HttpMapTileDataSource();
dataSource.UriRequested +=
new TypedEventHandler<HttpMapTileDataSource, MapTileUriRequestedEventArgs>(
(source, args) => {
Rect mercBounds = GlobalMercator.TileBounds(
new Tile(args.X, args.Y), args.ZoomLevel);
args.Request.Uri = new Uri(string.Format(_wmsUrl, mercBounds.Left,
Math.Abs(mercBounds.Bottom), mercBounds.Right, Math.Abs(mercBounds.Top))); ;
});
_map.TileSources.Add(new MapTileSource(dataSource));
Tested on Windows 8.1 64bit, and Lumia 810, Windows Phone 8.1
enjoy.
Credits: got help here to repair problems with USB connection to my Lumia 810 (had to uninstall USB driver for the phone in device manager) and here to get WP8.1 on Lumia 810
Thank you for this post, it is very helpfull for me! I just want to ask you something about Map tiles. I’m developing a Windows Phone 8.1 app that shows a map and I have to show a wms layer (with HttpMapTileDataSource) in a specific point of the map and update it (with others wms calls) when the user zooms in/out or moves the map.
I saw that in your code sample you make just one calls at the beginning and you put one time the layer. But if I have to change the image retrived from the wms service accordly to the current view, how can I make it?
Thank you very much again for your post!
check the code again for inlined delegate that is called for each tile where you can do further customisation. Besides this you can remove/add layer based on your map viewport.
(source, args) => {
..calculates bounds and returns URL for each tile
});