/// <summary> /// Overrides the base CreateGroup method to ensure that new groups are GeoGroups. /// </summary> protected override void OnCreateGroup() { MapGroup grp = new MapGroup(Layers, ParentMapFrame, ProgressHandler); grp.LegendText = "New Group"; }
public bool ImportSQLite(string filePath, string name, bool addedFromProjectLoad) { Model.Geometry.SpatiaLite.Database db = new Model.Geometry.SpatiaLite.Database(filePath); List <IFeatureSet> dataset = null; bool ok = true; ok = db.TryLoadSpatialDataset(out dataset); if (!ok) { MessageBox.Show("Unable to load spatial dataset from file '" + filePath + "': " + db.ErrorMessage); return(false); } DotSpatial.Controls.MapGroup mapGroup = new DotSpatial.Controls.MapGroup(); mapGroup.LegendText = name; mapGroup.SelectionEnabled = true; foreach (var fs in dataset) { var mapLayer = GetMapLayerFromFeatureSet(fs); mapLayer.SelectionEnabled = true; //group.Layers.Add(layer); mapGroup.Layers.Add(mapLayer); mapLayer.SetParentItem(mapGroup); var id = Guid.NewGuid().ToString(); //this.idMapLayer[id] = mapLayer; //this.idMapLayerInverse[mapLayer] = id; mapGroup.Layers[mapGroup.Layers.Count - 1].LegendText = fs.Name; } foreach (var layer in mapGroup.Layers) { //if (!layer.Projection.Equals(this.map.MapFrame.Projection)) // If we don't reproject upon load for every layer, then the layers don't display properly. layer.Reproject(this.map.MapFrame.Projection); IMapFeatureLayer fl = layer as IMapFeatureLayer; if (fl != null) { //LayerAdded(fl); } } this.map.Layers.Add(mapGroup); //var id = Guid.NewGuid().ToString(); //this.idMapGroupInverse[mapGroup] = id; //this.idMapGroup[id] = mapGroup; mapGroup.IsExpanded = false; //if (!this.mapSymbolHelper.LoadSymbology(mg, file, this)) //{ // return false; //} if (!addedFromProjectLoad) { this.projectMgr.SetProperty(Section_Layers, name, filePath); } return(true); }