Search code examples
c#.netwmsmapsui

Getting a WMS ImageLayer and layering it over an OpenStreetMap Layer - WPF


I am trying to get the map from a WMS to layer on a MapsUI map. However the WMS layer does not appear on the map. I have a simple view with just a MapControl (mapControl)

//create wms layer
public async Task CreateLayerAsync()
{
    var layer =  new ImageLayer("NOAA WMS")
    {
        DataSource = await CreateWmsProviderAsync(),
        Style = new RasterStyle()
    };
    mapControl.Map?.Layers.Add(layer);
}

private static async Task<WmsProvider> CreateWmsProviderAsync()
{
    const string wmsUrl = "https://mapservices.weather.noaa.gov/eventdriven/services/radar/radar_base_reflectivity_time/ImageServer/WMSServer";

    var provider = await WmsProvider.CreateAsync(wmsUrl);
    provider.ContinueOnError = true;
    provider.TimeOut = 20000;
    provider.CRS = "EPSG:84";
    provider.AddLayer("0");
    provider.SetImageFormat(provider.OutputFormats[1]);
    return provider;
}

The link to the WMS GetCapabilities document is here.

Any ideas? This is my first time diving into GIS and map rendering, so any pointers would be appreciated.


Solution

  • If you show this map on top of the often use osm tile layer you need to set the CRS like this: provider.CRS = "EPSG:3857";

    If you want to show the NOAA layer without other layers you could use provider.CRS = "EPSG:4326";. and not EPSG:84