thanks for tip, I check it many times but it does not work,
1. code sample:
private async Task WmsWaw()
{
SpatialReference sr = new SpatialReference(2180);
this.MyMapView.Map = new Map()
{
SpatialReference = sr
};
Esri.ArcGISRuntime.Layers.WmsLayer wms = new Esri.ArcGISRuntime.Layers.WmsLayer(new Uri("http://wms.um.warszawa.pl/serwis"));
await wms.InitializeAsync();
string name = "WMS/Raster_orto2010_10cm";
wms.Layers = new List<string>() { name };
var nameLayerInfo = wms.ServiceInfo.RootLayer.ChildLayers.FirstOrDefault(l => l.Name == name);
this.MyMapView.Map.Layers.Add(wms);
var extent = nameLayerInfo.Extent;
if (nameLayerInfo.Extent.SpatialReference.Wkid != sr.Wkid)
extent = GeometryEngine.Project(nameLayerInfo.Extent, sr).Extent;
this.MyMapView.Map.InitialViewpoint = new Viewpoint(extent);
await this.MyMapView.LayersLoadedAsync();
}
Spatial references:
Map 2180
MapView 4326
MapView Extent Envelope[XMin=21.0472112879068, YMin=52.222082410043, XMax=21.0491953019784, YMax=52.2232987533104, Wkid=4326]
so map stil works in 4326
wms.warszawa.pl in root layer informs that supported spatial references is only 4326, child layers have more: 4326 and 2180
2. code sample
private async Task AddGeoportal2()
{
SpatialReference sr = new SpatialReference(2180);
this.MyMapView.Map = new Map()
{
SpatialReference = sr
};
Esri.ArcGISRuntime.Layers.WmsLayer wms = new Esri.ArcGISRuntime.Layers.WmsLayer(new Uri("http://mapy.geoportal.gov.pl/wss/service/pub/guest/G2_GO_WMS/MapServer/WMSServer"));
await wms.InitializeAsync();
var ex = wms.ServiceInfo.RootLayer.Extent;
if (ex.SpatialReference.Wkid != sr.Wkid)
ex = GeometryEngine.Project(ex, sr).Extent;
this.MyMapView.Map.Layers.Add(wms);
this.MyMapView.Map.InitialViewpoint = new Viewpoint(ex);
await this.MyMapView.LayersLoadedAsync();
}
although wms service in root layer has 2180 map still works in 4326
a. I think that you should allow to set expected spatialReference in wmsLayer, it should help in code sample 2
b. when you collect supported spatial refernces you should also take it from child layers, it should help in code sample 1
final efect is that I cant create map with wms layer, even though service return valid data in 2180 with feature layers in 2180
Do I miss sth, or is other workaround ?
Regards,
Robert