Issue in Displaying WMS Layer with Different Spatial Reference on Map

287
1
01-10-2024 12:31 AM
Labels (3)
Muhammadkhalid
New Contributor II

In WPF application I am encountering difficulties displaying a WMS layer using .Net Maps SDK(200.2) when the layer and the map have different spatial references.

If I create the map and WMS layer both with a spatial reference of 4326(wms layer has this), everything displays correctly.
However, when I attempt to create the map with a spatial reference of 3857 and load the WMS layer with spatial reference 4326, the layer does not display.

How can I properly handle the display of layer if it has a different spatial reference from map

Here's the snippet of the code:

private async void DisplayWMSLayer(object sender, RoutedEventArgs e)
{
Uri _wmsUrl = new Uri("https://crop.csiss.gmu.edu/cgi-bin/wms_cdl_ia?");

List<string> layerNames = new List<string>();
string strSelectedLayerName = "cdl_2020_ia";
layerNames.Add(strSelectedLayerName);
WmsLayer wmsLayer = new WmsLayer(_wmsUrl, layerNames);
await wmsLayer.LoadAsync();
SpatialReference mapSpatialReference = SpatialReference.Create(3857);//if i use 4326 then display layer correctly
Map nMap = new Map(mapSpatialReference);

nMap.OperationalLayers.Add(wmsLayer);
nMap.InitialViewpoint = new Viewpoint(wmsLayer.FullExtent);
MainMapView.Map = nMap;
}


0 Kudos
1 Reply
ThadTilton
Esri Contributor

I believe the WMS service defines a list of supported spatial references that you can use. If you check the capabilities for the service here: https://crop.csiss.gmu.edu/cgi-bin/wms_cdl_ia/cdl_2020_ia/wms?SERVICE=WMS&REQUEST=GetCapabilities

You'll see that the layers define the following spatial references (CRS):

<CRS>epsg:5070</CRS>
<CRS>epsg:102004</CRS>
<CRS>epsg:4326</CRS>
0 Kudos