1

Resolved

Bug in OverviewMap

description

If you try to apply a new template to the OverviewMap and a layer has already been added to the map, it throws an exception saying that the Layer is already associated with another map. The reason this is happening is because in OnApplyTemplate, a new map is created and the current layer is added to the new map. The solution is to make sure to remove the layer from the old map before adding it to the new map. Here is the fixed OnApplyTemplate function:
 
public override void OnApplyTemplate()
{
        base.OnApplyTemplate();
        /*** FIX HERE: Remove the layer from the current map before we add it to the new map */
        if (this.Layer != null && OVMapImage != null)
        {
            OVMapImage.Layers.Remove(this.Layer);
        }
       OVMapImage = GetTemplateChild("OVMapImage") as Map; 
       .
       .
       .
       if (this.Layer != null)
       {
            this.OVMapImage.Layers.Add(this.Layer);
       }
       .
       .
       .
}

comments

mnielsen wrote Feb 1, 2010 at 11:37 PM

Similar issue exists in MagnifyingGlass. Both will be fixed in the upcoming v1.2
Thank you for reporting this!

wrote Feb 21, 2013 at 10:45 PM

wrote May 16, 2013 at 10:25 AM

wrote May 16, 2013 at 10:25 AM

wrote Jun 14, 2013 at 7:20 AM