private void InitDockLayout() { _mapForm = new ControlMapForm(); _mapForm.Text = "GIS地图"; _mapForm.Show(dockPanel1, DockState.Document); _mapForm.CloseButton = false; _mapForm.UiInitAndInvoke(); _mapForm.Activate(); MouseMoveOperator mouseMoveOperate; MouseDownOperator mouseDownOperate; sfHandle = new ShapeFileHandle(_mapForm.Map); #region 加载gis地图 string[] str = { @"D:\光纤传感监测系统\Monitor\Monitor\data\底图.shp", @"D:\光纤传感监测系统\Monitor\Monitor\data\省界WGS 84.shp", @"D:\光纤传感监测系统\Monitor\Monitor\data\海缆WGS 84.tif" }; mapLayer = new MapLayer(); MainLayerHandle = mapLayer.AddLayer(_mapForm.Map, str, "底图"); _mapForm.MainLayerHandle = MainLayerHandle; _mapForm.SetMainLayerHandle(); #endregion // _mapForm.Map.ZoomToMaxExtents(); _mapForm.Map.ZoomToLayer(MainLayerHandle); #region 在地图上划线 ClassLine line = new ClassLine(); ClassLine line_1 = new ClassLine(); GisPoint gisPoint = new GisPoint(); LineSet lineSet = new LineSet(tkMapColor.Yellow, 6.0f, tkDashStyle.dsSolid); LineSet lineSet_1 = new LineSet(tkMapColor.Red, 5.0f, tkDashStyle.dsCustom); gisPoint.connectToDB("Data Source=" + new DirectoryInfo("../../../../").FullName + "Monitor\\Monitor\\data\\data.db"); gisPoint.readData(); gisPoint.InitLineData(line); line_1.startX = gisPoint.m_PointList[15].X; line_1.startY = gisPoint.m_PointList[15].Y; line_1.endX = gisPoint.m_PointList[20].X; line_1.endY = gisPoint.m_PointList[20].Y; drawLine = new classDrawLine(_mapForm.Map); drawLine.WriteLine(line, lineSet); drawLine.WriteLine(line_1, lineSet_1); #endregion #region 在gis地图中添加ais数据 //1、获取数据库中数据 SqliteData sqlite = new SqliteData("Data Source=" + new DirectoryInfo("../../../../").FullName + "Monitor\\Monitor\\data\\data.db"); DataTable gisData = sqlite.readData("Point"); //2、实例化AISData类 ais = new AISData(_mapForm.Map, gisData); drawPoint_Ais = new classDrawPoint(MapForm.Map); //3、在地图上加载ais数据 pointSet = new PointSet("AisReal", tkDefaultPointSymbol.dpsTriangleUp, tkMapColor.Red, 16); drawPoint_Ais.CreatPoint(ais.point, pointSet); drawPoint_Ais.EditAttribute(); sfHandle.AddMouseMoveShapeFile("Ais", drawPoint_Ais.LayerHandle); #endregion #region drawPoint = new classDrawPoint(_mapForm.Map); var pnt = new ClassPoint(); pnt.x = 121.907567728461; pnt.y = 30.8729913928844; pnt.str = "图片详情"; string path = new DirectoryInfo("../../../../").FullName + "Monitor\\Monitor\\data\\ship3.png"; drawPoint.AddPicture(pnt, path); drawPoint.EditAttribute(); sfHandle.AddMouseDownShapeFile("pic", drawPoint.LayerHandle); #endregion _mapForm.Sf_MouseMove = sfHandle.Sf_MouseMove; _mapForm.Sf_MouseDown = sfHandle.Sf_MouseDown; mouseMoveOperate = new MouseMoveOperator(Operation.AddLabel); mouseDownOperate = new MouseDownOperator(Operation.AddLabel); //传入委托 MapForm.MouseMoveOperate = mouseMoveOperate; MapForm.mouseDownOperate = mouseDownOperate; //var point = new ClassPoint(); //point.x = 121.907567728461; //point.y = 30.8739913928844; //addText = new classAddText(_mapForm.Map, MainLayerHandle); //addText.AddText(point.x, point.y); }