private void OnClear(object sender, EventArgs e) { if (MapControl == null) { return; } var map = MapControl.Map; if (_layer != null && map.Layers.Contains(_layer)) { map.Layers.Remove(_layer); _layer.Dispose(); _layer = null; } }
/// <inheritdoc/> protected override void OnMapControlChangedInternal(EventArgs e) { base.OnMapControlChangedInternal(e); if (MapControl == null) { _layer.Dispose(); _layer = null; Enabled = false; return; } _geometryProvider = new Data.Providers.GeometryProvider((GeoAPI.Geometries.IGeometry)null); _layer = new Layers.VectorLayer("_tmp_Geometries", _geometryProvider); MapControl.ActiveToolChanged += OnMapControlActiveToolChanged; MapControl.GeometryDefined += OnGeometryDefined; }