Update MapBase.cs

This commit is contained in:
ClemensFischer 2025-08-08 20:31:12 +02:00
parent 3fc839c67a
commit f97a3f0797

View file

@ -444,7 +444,10 @@ namespace MapControl
{ {
if (oldLayer != null) if (oldLayer != null)
{ {
Children.Remove(oldLayer); if (Children.Count > 0 && Children[0] == oldLayer)
{
Children.RemoveAt(0);
}
if (oldLayer is IMapLayer mapLayer) if (oldLayer is IMapLayer mapLayer)
{ {
@ -460,8 +463,11 @@ namespace MapControl
} }
if (newLayer != null) if (newLayer != null)
{
if (Children.Count == 0 || Children[0] != newLayer)
{ {
Children.Insert(0, newLayer); Children.Insert(0, newLayer);
}
if (newLayer is IMapLayer mapLayer) if (newLayer is IMapLayer mapLayer)
{ {