If I use the WmsOverlay I have no displacement. The problem is, that I can not use the WmsOverlay, because I have to wms layer which are nestes in each other. So I have for example:
Wms Layer 1 - background
Wms Layer 2 - Rivers
Wms Layer 1 - Cities
Wms Layer 2 - Something
I hope you understand the problem? I use the same layer more than once. If I try to use the same Uri in a second WmsOverlay (on the same map) I get the exception "Ein Element mit dem gleichen Schlüssel wurde bereits hinzugefügt." - This says that a key with the same Uri (I think this is your key?) exists.
bei System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
bei System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
bei System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
bei System.Collections.ObjectModel.Collection`1.Add(T item)
bei Default_.Page_Load(Object sender, EventArgs e) in c:\MyProject\project\Default.aspx.cs:Zeile 68.
bei System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
bei System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
The second problem which is found, is that I can not set change the projection of WmsOverlay, if the layer is no BaseOverlay (standard is 4326 - I will use 25833). I try 2 codes:
Sample 1: I see the wms layer, but I can not set something in Background, but I will see the world in background...
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
Map1.CurrentExtent = new RectangleShape(240000, 5930000, 490000, 5690000);
Map1.MapUnit = GeographyUnit.Meter;
WmsOverlay wmsOverlay1 = new WmsOverlay("WMS", new Uri("isk.geobasis-bb.de/ows/dnm.php"), TileType.SingleTile);
wmsOverlay1.Parameters.Add("layers", "bg,siedlung,vegetation,gewaesser,transport,strassennamen,ortsnamen,gewaessernamen");
wmsOverlay1.Parameters.Add("Exceptions", "application/vnd.ogc.se_xml");
wmsOverlay1.Parameters.Add("format", "image/png");
wmsOverlay1.Parameters.Add("transparent", "true");
wmsOverlay1.Parameters.Add("SRS", "EPSG:25833");
wmsOverlay1.IsBaseOverlay = true;
Map1.CustomOverlays.Add(wmsOverlay1);
Sample 2: I can not see the wms layer, if I change the projection and the layer is not in base overlay!
Map2.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
Map2.CurrentExtent = new RectangleShape(240000, 5930000, 490000, 5690000);
Map2.MapUnit = GeographyUnit.Meter;
Map2.MapTools.OverlaySwitcher.Enabled = true;
WmsOverlay wmsOverlay2 = new WmsOverlay("WMS", new Uri("isk.geobasis-bb.de/ows/dnm.php"), TileType.SingleTile);
wmsOverlay2.Parameters.Add("layers", "bg,siedlung,vegetation,gewaesser,transport,strassennamen,ortsnamen,gewaessernamen");
wmsOverlay2.Parameters.Add("Exceptions", "application/vnd.ogc.se_xml");
wmsOverlay2.Parameters.Add("format", "image/png");
wmsOverlay2.Parameters.Add("transparent", "true");
wmsOverlay2.Parameters.Add("SRS", "EPSG:25833");
wmsOverlay2.IsBaseOverlay = false;
Map2.CustomOverlays.Add(wmsOverlay2);
The strange is, that I see the map from sample 2, if I put 2 maps on the form - sample1 and sample2. If I set the map from sample 1 to visible false, I see nothing in sample 2, if I set it to visible true I see the wms layer. I hope you understand me?
Sample 1 and sample 2 on the same page. Please try to set the map1 to visible = false and look to the result:
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
Map1.CurrentExtent = new RectangleShape(240000, 5930000, 490000, 5690000);
Map1.MapUnit = GeographyUnit.Meter;
WmsOverlay wmsOverlay1 = new WmsOverlay("WMS", new Uri("isk.geobasis-bb.de/ows/dnm.php"), TileType.SingleTile);
wmsOverlay1.Parameters.Add("layers", "bg,siedlung,vegetation,gewaesser,transport,strassennamen,ortsnamen,gewaessernamen");
wmsOverlay1.Parameters.Add("Exceptions", "application/vnd.ogc.se_xml");
wmsOverlay1.Parameters.Add("format", "image/png");
wmsOverlay1.Parameters.Add("transparent", "true");
wmsOverlay1.Parameters.Add("SRS", "EPSG:25833");
wmsOverlay1.IsBaseOverlay = true;
Map1.CustomOverlays.Add(wmsOverlay1);
// ToDo: try to set the map1 to visible = false;
Map1.Visible = false;
Map2.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
Map2.CurrentExtent = new RectangleShape(240000, 5930000, 490000, 5690000);
Map2.MapUnit = GeographyUnit.Meter;
Map2.MapTools.OverlaySwitcher.Enabled = true;
WmsOverlay wmsOverlay2 = new WmsOverlay("WMS", new Uri("isk.geobasis-bb.de/ows/dnm.php"), TileType.SingleTile);
wmsOverlay2.Parameters.Add("layers", "bg,siedlung,vegetation,gewaesser,transport,strassennamen,ortsnamen,gewaessernamen");
wmsOverlay2.Parameters.Add("Exceptions", "application/vnd.ogc.se_xml");
wmsOverlay2.Parameters.Add("format", "image/png");
wmsOverlay2.Parameters.Add("transparent", "true");
wmsOverlay2.Parameters.Add("SRS", "EPSG:25833");
wmsOverlay2.IsBaseOverlay = false;
Map2.CustomOverlays.Add(wmsOverlay2);