Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs =================================================================== diff -u -r0ac1c7531ea9705697f65e09fdaabd647f0f57c7 -r0280af2522389e4f1291c22e0cbea677995e3fba --- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 0ac1c7531ea9705697f65e09fdaabd647f0f57c7) +++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 0280af2522389e4f1291c22e0cbea677995e3fba) @@ -31,7 +31,6 @@ using Core.Components.Gis.Forms; using DotSpatial.Controls; using DotSpatial.Data; -using DotSpatial.Symbology; using DotSpatial.Topology; namespace Core.Components.DotSpatial.Forms @@ -272,26 +271,14 @@ drawnMapData.Observer = new Observer(() => { - var newMapFeatureLayer = MapFeatureLayerFactory.Create(drawnMapData.FeatureBasedMapData); - - if (ReferenceEquals(drawnMapData.FeatureBasedMapData.Features, drawnMapData.Features)) + if (!ReferenceEquals(drawnMapData.FeatureBasedMapData.Features, drawnMapData.Features)) { - // Only update some properties when the array of drawn features is still the same - drawnMapData.MapFeatureLayer.IsVisible = newMapFeatureLayer.IsVisible; - ((FeatureLayer) drawnMapData.MapFeatureLayer).Name = ((FeatureLayer) drawnMapData.MapFeatureLayer).Name; - drawnMapData.MapFeatureLayer.ShowLabels = newMapFeatureLayer.ShowLabels; - drawnMapData.MapFeatureLayer.LabelLayer = newMapFeatureLayer.LabelLayer; - drawnMapData.MapFeatureLayer.Symbolizer = newMapFeatureLayer.Symbolizer; - } - else - { - // Otherwise redraw the feature layer and update the drawn map data lookup - var replaceIndex = map.Layers.IndexOf(drawnMapData.MapFeatureLayer); - map.Layers.RemoveAt(replaceIndex); - map.Layers.Insert(replaceIndex, newMapFeatureLayer); + MapFeatureLayerFactory.ConvertLayerFeatures(drawnMapData.FeatureBasedMapData, drawnMapData.MapFeatureLayer); + drawnMapData.Features = drawnMapData.FeatureBasedMapData.Features; - drawnMapData.MapFeatureLayer = newMapFeatureLayer; } + + MapFeatureLayerFactory.ConvertLayerProperties(drawnMapData.FeatureBasedMapData, drawnMapData.MapFeatureLayer); }) { Observable = featureBasedMapData Index: Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs =================================================================== diff -u -rf1533826e584432afb90f50645bad20a803eeac1 -r0280af2522389e4f1291c22e0cbea677995e3fba --- Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision f1533826e584432afb90f50645bad20a803eeac1) +++ Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision 0280af2522389e4f1291c22e0cbea677995e3fba) @@ -64,6 +64,7 @@ ConvertLayerFeatures((TFeatureBasedMapData) data, (TMapFeatureLayer) layer); layer.DataSet.InitializeVertices(); + layer.AssignFastDrawnStates(); } public void ConvertLayerProperties(FeatureBasedMapData data, IFeatureLayer layer) @@ -110,7 +111,7 @@ protected static void ClearLayerData(IFeatureLayer layer) { layer.DataSet.Features.Clear(); - layer.DataSet.DataTable.Clear(); + layer.DataSet.DataTable.Reset(); } protected static void SetDataTableColumns(FeatureBasedMapData data, IFeatureLayer layer) Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs =================================================================== diff -u -r675771641656abfb56ef89be86bad7bd21684016 -r0280af2522389e4f1291c22e0cbea677995e3fba --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 675771641656abfb56ef89be86bad7bd21684016) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 0280af2522389e4f1291c22e0cbea677995e3fba) @@ -107,7 +107,7 @@ } [Test] - public void GivenMapControlWithData_WhenMapDataNotifiesFeaturesChange_CorrespondingLayerReplaced() + public void GivenMapControlWithData_WhenMapDataNotifiesFeaturesChange_CorrespondingLayerReused() { // Given using (var map = new MapControl()) @@ -137,7 +137,7 @@ // Assert Assert.AreEqual(3, mapView.Layers.Count); Assert.AreSame(layersBeforeUpdate[0], mapView.Layers[0]); - Assert.AreNotSame(layersBeforeUpdate[1], mapView.Layers[1]); + Assert.AreSame(layersBeforeUpdate[1], mapView.Layers[1]); Assert.AreSame(layersBeforeUpdate[2], mapView.Layers[2]); } }