// 更新目标位置 private bool UpdatePlanePosition(Plane plane) { var layer = mapLogic.GetLayer(plane.LayerName); if (layer == null) { return(false); } var element = layer.GetElement(plane.Name); if (element == null) { return(false); } IMFPicture picture = element as IMFPicture; if (picture == null) { return(false); } picture.UpdatePosition(plane.Coordinate); if (plane.TargetType == 0) // 只有飞机才设置方位角 { picture.SetAngle((float)plane.Azimuth); } layer.Refresh(); return(true); }
// 设置设备显示、隐藏 public void SetDeviceVisible(string deviceName, bool visible) { IMFLayer layer = mapLogic.GetLayer("设备服务图层"); if (layer == null) { return; } IMFElement element = layer.GetElement(deviceName); if (element != null) { IMFPicture picture = element as IMFPicture; if (picture != null) { picture.SetVisible(visible); } } IMFElement ele = layer.GetElement(deviceName + "polygon"); if (ele != null) { IMFCircle circle = ele as IMFCircle; if (circle != null) { circle.SetVisible(visible); } } }
// 设置要跟踪的目标 public void SetTrackElement(IMFPicture element, bool bTrack) { trackPicture = element; if (bTrack == false) { trackPicture = null; } }
// 删除目标 private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { try { if (prevPicture != null) { mapBusiness.DeletePlane(prevPicture.BelongLayer.LayerName, prevPicture.ElementName); prevPicture = null; } } catch (Exception ex) { Log4Allen.WriteLog(typeof(GMapControlEx), ex.Message); } }
/// <summary> /// 清理态势数据 /// </summary> public void ClearRealData() { try { for (int i = 0; i < 4; i++) { mapLogic.RemoveLayer(GetModelLayerName((byte)i)); // 移除图层 } planeMgr.ClearData(); trackMgr.ClearData(); trackPicture = null; } catch (System.Exception ex) { Log4Allen.WriteLog(typeof(ArcGlobeBusiness), ex.Message); } }
private void 添加ToolStripMenuItem_Click(object sender, System.EventArgs e) { System.Diagnostics.Debug.WriteLine("添加点程序线程ID" + Thread.CurrentThread.ManagedThreadId); for (int i = 0; i < 5000; i++) { Kml kml = new Kml(); string iconUrl = AppDomain.CurrentDomain.BaseDirectory + @"Image\hoverplane.png"; kml.Placemark.Name = "point" + i; MapLngLat lnglat = new MapLngLat(random.Next(-18000, 18000) / 100, random.Next(-9000, 9000) / 100); kml.Placemark.Graph = new KmlPicture() { Position = lnglat, IconUrl = iconUrl, Scale = 1, TipText = "标牌测试...." }; mapLogic.GetLayer(drawLayerName).AddElement(kml, out element); picElement = element as IMFPicture; picList.Add(picElement); } }
// 地图点击事件 private void Map_ElementClickEvent(object sender, MFElementClickEventArgs e) { if (e.Element == null) { return; } switch (e.Element.ElementType) { case ElementTypeEnum.Picture: IMFPicture picture = e.Element as IMFPicture; if (picture == null) { return; } if (prevPicture != null) { prevPicture.HightLight(false); } picture.HightLight(true); prevPicture = picture; if (e.MouseEventArgs.Button == MouseButtons.Right) { Point screenLocation = new Point(e.MouseEventArgs.X + this.Parent.Location.X + this.Parent.Parent.Location.X + this.Parent.Parent.Parent.Location.X + this.Parent.Parent.Parent.Parent.Location.X, e.MouseEventArgs.Y + this.Parent.Location.Y + this.Parent.Parent.Location.Y + this.Parent.Parent.Parent.Location.Y + this.Parent.Parent.Parent.Parent.Location.Y); contextMenuStrip1.Show(screenLocation); } break; default: if (bEdit == true && e.Element != null) { // 只能编辑已绘制的图元 var editElement = drawElements.Find(o => o.ElementName == e.Element.ElementName); if (editElement != null) { toolBox.EditElement(editElement); } } break; } }
// 更新目标 private bool UpdateElement(RealData data) { var layer = mapLogic.GetLayer(objLayer); if (layer == null) { return(false); } string name = data.TargetNum.ToString(); if (!elementMgr.IsHaveElement(name)) { return(false); } var element = mapLogic.GetLayer(objLayer).GetElement(name); if (element == null) { return(false); } IMFPicture picElement = element as IMFPicture; if (picElement == null) { return(false); } // 更新目标位置 picElement.UpdatePosition(data.Longitude, data.Latitude); // 更新目标航迹 if (trackMgr.IsShowTrack(name)) { UpdateElementTrackLine(name); } return(true); }
/// <summary> /// 跳转到某目标 /// </summary> /// <param name="name"></param> public void JumpToPlane(byte type, string elementName) { if (mapLogic == null) { return; } IMFLayer layer = mapLogic.GetLayer(GetModelLayerName(type)); if (layer == null) { return; } IMFElement element = layer.GetElement(elementName); if (element == null) { return; } IMFPicture model = element as IMFPicture; if (model == null) { return; } MapLngLat position = model.GetLngLat();; IMFToolBox toolBox = mapLogic.GetToolBox(); if (toolBox == null) { return; } toolBox.ZoomToPosition(position); }