ThinkGeo.com    |     Documentation    |     Premium Support

Clearing objects from InMemoryMarkerOverlay

Hi,



I’m having trouble clearing the objects from an InMemoryMarkerOverlay.   The code below shows a single marker on a solid background.



Excuting the Clear method, clears the background layer, but the image for the MarkerOverlay layer is still present.



How do I clear this from the map?



Thanks,

Steve


private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap.MapUnit = GeographyUnit.DecimalDegree;
 
            var layerOverlay = new LayerOverlay();
            layerOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.Tundra)));
            wpfMap.Overlays.Add(layerOverlay);
 
            var pointLayer = new InMemoryMarkerOverlay();
            var uri = new Uri(@“D:\Temp\AQUA.png”);
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.ImageSource = new BitmapImage(uri);
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Width = 20;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Height = 34;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.YOffset = -17;
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
 
            wpfMap.Overlays.Add(pointLayer);
 
            pointLayer.FeatureSource.BeginTransaction();
 
            var pointShape = new PointShape(-111, -50);
            var pointFeature = new Feature(pointShape);
            pointLayer.FeatureSource.AddFeature(pointFeature);
 
            pointLayer.FeatureSource.CommitTransaction();
 
            wpfMap.Refresh();
        }
 
        private void ClearClick(object sender, RoutedEventArgs e)
        {
            wpfMap.Overlays.Clear();
            wpfMap.Refresh();
        }


Hi Steve, 



I have reproduced that. It should be an issue. 



As below is just a workaround which maybe smell bad. We will update the post after fixed the bug: 



pointLayer.FeatureSource.Clear();


Map1.Refresh(pointLayer);


Map1.Overlays.Clear();


Map1.Refresh();






Regards,



Don

Hi Steve, 
  
 We have fixed this bug, you can get it in 7.0.0.39(39.0) or any higher version. 
  
 Regards, 
  
 Don

Thanks.   I tried 7.0.0.42 and it worked fine.

Hi Steve,  
  
 Thank you very much for let us know this bug! 
  
 Regards, 
  
 Don