首页 / 浏览问题 / 组件GIS / 问题详情
winfrom GeoPicture 点击事件
18EXP 2019年07月09日
public static GeoPicture GetPic(double x, double y, string imageFile,int  index )
        {
            Point2D p2d=new Point2D();
            p2d.X = x;
            p2d.Y =y;            
            
            GeoPicture pic = new GeoPicture(imageFile, p2d, 20, 20, 0);     
            pic.ID = index;       
            return pic;
        }
        //创建数据集
        public static Datasource CreateDatasources(string name)
        {
             DatasourceConnectionInfo info = new DatasourceConnectionInfo();
             info.EngineType = EngineType.UDB;
               
             info.Server = ":memory:";//内存数据源
             info.Alias =name;//别名
             Datasource datasource = workspace.Datasources.Create(info);
             return datasource;
        }
        public static ImportSettingDWG importdwg(string datasourceName,string name,string filename)
        {
            ImportSettingDWG dwg = new ImportSettingDWG();
            dwg.TargetDatasource = workspace.Datasources[datasourceName];
            dwg.TargetDatasetName = name;
         
            dwg.SourceFilePath = filename;

            dwg.IsImportAs3D = true;
            dwg.ImportMode = ImportMode.Overwrite;

            return dwg;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            
            
            WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
            workspaceConnectionInfo.Type = WorkspaceType.SMWU   ;
            String file = @"E\xu.smwu";
            workspaceConnectionInfo.Server = file;
            if (workspace.Create(workspaceConnectionInfo))
            {
                Console.WriteLine("创建工作空间成功");

                Datasource datasource_fod = CreateDatasources("fod");
                
                if (datasource_fod != null)
                {
                    Console.WriteLine("创建数据集成功");   
                    DataImport import = new DataImport();
                    ImportSettingDWG dwg = importdwg("fod", "fod", @"fod\fod.dwg");
                    import.ImportSettings.Add(dwg);
                    
                    ImportResult result = import.Run();
                    workspaceTree1.Workspace = workspace;              
                    mapControl1.Map.Workspace = workspace;
                    if (result.SucceedSettings.Length != 0)
                    {

                        

                       Layer la=  mapControl1.Map.Layers.Add(workspace.Datasources[0].Datasets[0], true);

                       

                        string imageFile = @"fod\绿色.png";                      
                         mapControl1.Map.TrackingLayer.Add(GetPic(40, 140, imageFile, 1), "A1");
                         mapControl1.Map.TrackingLayer.Add(GetPic(80, 140, imageFile, 2), "A2");
                         mapControl1.Map.TrackingLayer.Add(GetPic(120, 140, imageFile, 3), "A3");
                         mapControl1.Map.TrackingLayer.Add(GetPic(160, 140, imageFile, 4), "A4");
                         mapControl1.Map.TrackingLayer.Add(GetPic(200, 140, imageFile, 5), "A5");
                         mapControl1.Map.TrackingLayer.Add(GetPic(240, 140, imageFile, 6), "A6");
                         mapControl1.Map.TrackingLayer.Add(GetPic(280, 140, imageFile, 7), "A7");
                         mapControl1.Map.TrackingLayer.Add(GetPic(320, 140, imageFile, 8), "A8");

                         mapControl1.Map.TrackingLayer.Add(GetPic(40, 55, imageFile, 9), "B1");
                         mapControl1.Map.TrackingLayer.Add(GetPic(80, 55, imageFile, 10), "B2");
                         mapControl1.Map.TrackingLayer.Add(GetPic(120, 55, imageFile, 11), "B3");
                         mapControl1.Map.TrackingLayer.Add(GetPic(160, 55, imageFile, 12), "B4");
                         mapControl1.Map.TrackingLayer.Add(GetPic(200, 55, imageFile, 13), "B5");
                         mapControl1.Map.TrackingLayer.Add(GetPic(240, 55, imageFile, 14), "B6");
                         mapControl1.Map.TrackingLayer.Add(GetPic(280, 55, imageFile, 15), "B7");
                         mapControl1.Map.TrackingLayer.Add(GetPic(320, 55, imageFile, 16), "B8");

                         Layer m_regionLayer;
                         DatasetVectorInfo regionLayerInfo = new DatasetVectorInfo("region", DatasetType.Region);
                         regionLayerInfo.Name = "aaa";

                        

                         DatasetVector regionDataset = workspace.Datasources[0].Datasets.Create(regionLayerInfo);
                         
                         m_regionLayer = mapControl1.Map.Layers.Add(regionDataset, true);

                         

                         mapControl1.Map.Refresh();

                    }
                }

            }

           
            
            // 释放资源
          //  workspace.Close();
          //  workspace.Dispose();
           // workspaceConnectionInfo.Dispose();
           
        }

1个回答

您好,你这边是想通过点击geopicture实现怎样的需求,我们这边有GeometrySelected点击事件,在Mapcontrol类下的事件里面
2,432EXP 2019年07月09日
...