/// <summary> /// 创建图元 /// </summary> /// <param name="kml"></param> /// <param name="layer"></param> /// <returns></returns> public IMFElement CreateElement(Kml kml, ILayer layer) { KmlText textKml = kml.Placemark.Graph as KmlText; if (textKml == null) { return(null); } if (textKml.Position == null) { return(null); } int index = -1; //图层 IGlobeGraphicsLayer graphicsLayer = layer as IGlobeGraphicsLayer; MapFrame.ArcGlobe.Element.Text_ArcGlobe textElement = null; this.Dosomething((Action) delegate() { //图元 textElement = new MapFrame.ArcGlobe.Element.Text_ArcGlobe(graphicsLayer, textKml); GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass(); properties.Rasterize = textKml.Rasterize; graphicsLayer.AddElement(textElement, properties, out index); textElement.Index = index; //指定索引 textElement.ElementName = kml.Placemark.Name; }, true); return(textElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图元的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public IMFElement CreateElement(Kml kml, ILayer layer) { KmlPolygon polygonKml = kml.Placemark.Graph as KmlPolygon; if (polygonKml == null) { return(null); } if (polygonKml.PositionList == null) { return(null); } int index = -1; Polygon_ArcGlobe polygonElement = null; this.Dosomething((Action) delegate() { //图层 IGlobeGraphicsLayer graphicsLayer = layer as IGlobeGraphicsLayer; //实例化图元 polygonElement = new Polygon_ArcGlobe(graphicsLayer, polygonKml); //设置属性 GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass(); properties.Rasterize = polygonKml.Rasterize; graphicsLayer.AddElement(polygonElement, properties, out index); polygonElement.Index = index; //指定索引 polygonElement.ElementName = kml.Placemark.Name; }, true); return(polygonElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml"></param> /// <param name="layer"></param> /// <returns></returns> public IMFElement CreateElement(Kml kml, ILayer layer) { KmlPoint pointKml = kml.Placemark.Graph as KmlPoint; if (pointKml.Position == null) { return(null); } int index = -1; //图层 IGlobeGraphicsLayer graphicsLayer = layer as IGlobeGraphicsLayer; //图元 Point_ArcGlobe pointElement = new Point_ArcGlobe(graphicsLayer, pointKml); this.Dosomething((Action) delegate() { IGlobeGraphicsElementProperties properties = new GlobeGraphicsElementPropertiesClass(); properties.Rasterize = pointKml.Rasterize; //栅格化 graphicsLayer.AddElement(pointElement, properties, out index); pointElement.Index = index; //指定索引 pointElement.ElementName = kml.Placemark.Name; }, true); return(pointElement); }
/// <summary> /// 设置图层栅格化 /// </summary> /// <param name="layerName">图层名称</param> /// <param name="bRasterize">是否栅格化</param> public void SetRasterize(string layerName, bool bRasterize) { if (!layerDic.ContainsKey(layerName)) { return; } ILayer pLayer = layerDic[layerName]; Dosomething((Action) delegate() { IScene m_scene = globeControl.Globe as IScene; // 提供数据给成员控制场景 m_scene.ActiveGraphicsLayer = pLayer; // 活动的图层,如果没有则创建一个 IGlobeGraphicsLayer pGL = pLayer as IGlobeGraphicsLayer; //提供数据给地图图形图层 IGlobeDisplay m_globeDisplay = globeControl.Globe.GlobeDisplay; // 提供数据给成员操作地图显示 IGlobeDisplayLayers pGlobeLayer = m_globeDisplay as IGlobeDisplayLayers; // 提供数据给成员操作地图显示图层 IGlobeLayerProperties pGlobeLayerProps = pGlobeLayer.FindGlobeProperties(pLayer); // 提供数据给成员操纵图层属性,返回图层的属性 IGlobeGraphicsElementProperties pGEP = new GlobeGraphicsElementPropertiesClass(); // 图层的其他属性 pGEP.DrapeElement = true; pGEP.DrapeZOffset = 10; pGEP.Rasterize = bRasterize; //是否栅格化 pGlobeLayerProps.ApplyDisplayProperties(pLayer); //应用属性到此图层 }, true); }
/// <summary> /// 添加图元 /// </summary> /// <param name="kml"></param> /// <param name="layer"></param> /// <returns></returns> public IMFElement CreateElement(Kml kml, ILayer layer) { KmlCircle circleKml = kml.Placemark.Graph as KmlCircle; if (circleKml.Position == null) { return(null); } int index = -1; Circle_ArcGlobe circleElement = null; this.Dosomething((Action) delegate() { //图元 IGlobeGraphicsLayer graphicsLayer = layer as IGlobeGraphicsLayer; circleElement = new Circle_ArcGlobe(graphicsLayer, circleKml); IGlobeGraphicsElementProperties properties = new GlobeGraphicsElementPropertiesClass(); properties.Rasterize = circleKml.Rasterize; graphicsLayer.AddElement(circleElement, properties, out index); circleElement.Index = index; circleElement.ElementName = kml.Placemark.Name; }, true); return(circleElement); }
/// <summary> /// 构造函数 /// </summary> /// <param name="_graphicsLayer">图层</param> /// <parparam name="polygonKml">面的kml</parparam> public Polygon_ArcGlobe(IGlobeGraphicsLayer _graphicsLayer, KmlPolygon polygonKml) { this.graphicsLayer = _graphicsLayer; this.ElementType = ElementTypeEnum.Polygon; //图元类型 this.Description = polygonKml.Description; //图元描述 #region 符号 simpleFillSymbol = new SimpleFillSymbolClass(); simpleLineSymbol = new SimpleLineSymbolClass(); IRgbColor fillColor = new RgbColorClass(); fillColor.Transparency = polygonKml.FillColor.A; fillColor.Red = polygonKml.FillColor.R; fillColor.Green = polygonKml.FillColor.G; fillColor.Blue = polygonKml.FillColor.B; this.opacity = polygonKml.FillColor.A; IRgbColor outlineColor = new RgbColorClass(); outlineColor.Transparency = polygonKml.OutLineColor.A; outlineColor.Red = polygonKml.OutLineColor.R; outlineColor.Green = polygonKml.OutLineColor.G; outlineColor.Blue = polygonKml.OutLineColor.B; simpleLineSymbol.Color = outlineColor; simpleLineSymbol.Width = polygonKml.OutLineSize; simpleFillSymbol.Color = fillColor; simpleFillSymbol.Outline = simpleLineSymbol; this.fillColor = polygonKml.FillColor; this.outlineColor = polygonKml.OutLineColor; this.outLineSize = polygonKml.OutLineSize; #endregion #region 位置 IGeometry geometry = new PolygonClass(); IPointCollection pointCollection = geometry as IPointCollection; IPoint point = new PointClass(); foreach (var item in polygonKml.PositionList) { point.PutCoords(item.Lng, item.Lat); point.Z = item.Alt; pointCollection.AddPoint(point); } (pointCollection as IZAware).ZAware = true; #endregion base.Geometry = pointCollection as IGeometry; //指定位置 base.Symbol = simpleFillSymbol; //指定符号 flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 500; }
public void AddElement(IElement element, IGlobeGraphicsElementProperties elementProperties) { int elementIndex; IGlobeGraphicsLayer globeGraphicsLayer = _layer as IGlobeGraphicsLayer; globeGraphicsLayer.AddElement(element, elementProperties, out elementIndex); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">模型的kml</param> /// <param name="layer">模型所在的图层</param> /// <returns></returns> public IMFElement CreateElement(Kml kml, ILayer layer) { KmlModel3d modelkml = kml.Placemark.Graph as KmlModel3d; if (modelkml == null) { return(null); } if (modelkml.Position == null) { return(null); } if (!File.Exists(modelkml.ModelFilePath)) { return(null); } int index = -1; //图层 IGlobeGraphicsLayer graphicLayer = layer as IGlobeGraphicsLayer; if (graphicLayer == null) { return(null); } //实例化图元 Model3d_ArcGlobe modelElement = null; //添加图元 this.Dosomething((Action) delegate() { IImport3DFile import3Dfile = null; if (!filePathDic.ContainsKey(modelkml.ModelFilePath)) { import3Dfile = new Import3DFileClass(); import3Dfile.CreateFromFile(modelkml.ModelFilePath); filePathDic.Add(modelkml.ModelFilePath, import3Dfile); } else//模型已创建 { import3Dfile = filePathDic[modelkml.ModelFilePath]; } modelElement = new Model3d_ArcGlobe(graphicLayer, modelkml, import3Dfile); //设置属性 GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass(); properties.Rasterize = modelkml.Rasterize; graphicLayer.AddElement(modelElement, properties, out index); modelElement.Index = index; modelElement.ElementName = kml.Placemark.Name; }, true); return(modelElement); }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); } globeGraphicsLayer = null; envelope = null; }
/// <summary> /// Adds a sphere element to the given graphics layer at the specified position /// </summary> /// <param name="globeGraphicsLayer"></param> /// <param name="position"></param> /// <returns></returns> private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position) { if (null == globeGraphicsLayer) { return(-1); } //create a new point at the given position IPoint point = new PointClass(); ((IZAware)point).ZAware = true; point.X = position.longitude; point.Y = position.latitude; point.Z = 0.0; //set the color for the element (red) IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 0; color.Blue = 0; //create a new 3D marker symbol IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //set the marker symbol's style and resolution ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //set the symbol's size and color markerSymbol.Size = 700; markerSymbol.Color = color as IColor; //crate the graphic element IElement trackElement = new MarkerElementClass(); //set the element's symbol and geometry (location and shape) ((IMarkerElement)trackElement).Symbol = markerSymbol; trackElement.Geometry = point as IPoint; //add the element to the graphics layer int elemIndex = 0; ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0); //get the element's index globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex); return(elemIndex); }
/// <summary> /// 构造函数 /// </summary> /// <param name="graphicsLayer"></param> /// <param name="textKml">文字kml</param> public Text_ArcGlobe(IGlobeGraphicsLayer graphicsLayer, KmlText textKml) { this.graphicsLayer = graphicsLayer; this.ElementType = ElementTypeEnum.Text; //图元类型 this.Description = textKml.Description; //图元描述 #region 位置 IPoint point = new PointClass() { X = textKml.Position.Lng, Y = textKml.Position.Lat, Z = textKml.Position.Alt }; (point as IZAware).ZAware = true; //base.Geometry = point; #endregion #region 符号 base.FixedAspectRatio = true; //表明是否固定界限比例 //this.ReferenceScale = 100;//设置固定比例,不知道具体作用 base.AnchorPoint = point; //锚 base.Text = textKml.Content; base.Height = textKml.Size; base.FontName = textKml.Font; base.AxisRotation = esriT3DRotationAxis.esriT3DRotateAxisX; //旋转轴 base.RotationAngle = -90; //旋转角度 Color _color = textKml.Color; IRgbColor color = new RgbColorClass() { Red = _color.R, Green = _color.G, Blue = _color.B }; fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = color; base.Symbol = fillSymbol; this.fontColor = textKml.Color; this.fontSize = textKml.Size; #endregion isFlash = false; flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 500; }
/// <summary> /// 构造函数 /// </summary> /// <param name="_graphcisLayer">图层</param> /// <param name="modelKml">模型kml</param> public Model3d_ArcGlobe(IGlobeGraphicsLayer _graphicLayer, KmlModel3d modelKml, IImport3DFile import3Dfile) { graphicLayer = _graphicLayer; this.ElementType = ElementTypeEnum.Model3D; // 图元类型 this.Description = modelKml.Description; // 图元描述 #region 符号 IGeometry geometry = import3Dfile.Geometry; //将模型转为3D符号 marker3DSymbol = new Marker3DSymbolClass(); marker3DSymbol.Shape = geometry; markerSymbol = marker3DSymbol as IMarkerSymbol; markerSymbol.Size = modelKml.Scale; markerSymbol.Angle = modelKml.Azimuth; IRgbColor c = new RgbColorClass(); c.Transparency = modelKml.Color.A; c.Red = modelKml.Color.R; c.Green = modelKml.Color.G; c.Blue = modelKml.Color.B; markerSymbol.Color = c; this.scale = modelKml.Scale; this.color = modelKml.Color; #endregion #region 位置 IPoint p = new PointClass(); p.PutCoords(modelKml.Position.Lng, modelKml.Position.Lat); p.Z = modelKml.Position.Alt; (p as IZAware).ZAware = true; #endregion lngLat = modelKml.Position; base.Geometry = p; //指定位置 base.Symbol = markerSymbol; //指定符号 flashTimer = new Timer(); flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 500; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); flashTimer = null; } layer = null; mapControl = null; pLineSymbol = null; graphcisLayer = null; index = -1; isTimer = false; isVisible = true; isHightLight = false; isFlash = false; properties = null; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); flashTimer = null; } markerSymbol = null; graphicsLayer = null; index = -1; isFlash = false; isVisible = true; isHightLight = false; isTimer = false; mapControl = null; layer = null; ElementProperties = null; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); } layer = null; lineSymbol = null; fillSymbol = null; graphicsLayer = null; isFlash = false; isHightlight = false; isVisible = false; upperAxisVector3D = null; normalVector3D = null; lowerAxisVector3D = null; geometryCollection = null; pointCollection = null; }
/// <summary> /// 释放 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); flashTimer = null; } layer = null; mapControl = null; marker3DSymbol = null; markerSymbol = null; index = -1; isTimer = false; isFlash = false; isVisible = true; isHightLight = false; graphicLayer = null; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); flashTimer = null; } mapControl = null; isHightlight = false; isVisible = true; isTimer = false; isFlash = false; index = -1; lockObj = null; fillSymbol = null; graphicsLayer = null; layer = null; properties = null; }
/// <summary> /// 构造函数 /// </summary> /// <param name="_graphicsLayer">图层</param> /// <param name="picKml">图片的kml</param> public Picture_ArcGlobe(IGlobeGraphicsLayer _graphicsLayer, Core.Model.KmlPoint picKml) { //this.ElementType = Core.Model.ElementTypeEnum.Picture; //globeGraphicsLayer = _graphicsLayer; //width = height = picKml.Scale; //positionPoint = picKml.Position; //envelope = new EnvelopeClass(); //envelope.PutCoords(picKml.Position.Lng, picKml.Position.Lat, picKml.Position.Lng + picKml.Scale, picKml.Position.Lat + picKml.Scale); //envelope.ZMax = picKml.Position.Alt; //IGeometry geometry = envelope as IGeometry; //base.Geometry = geometry; //base.ImportPictureFromFile(picKml.IconUrl); //GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass(); //properties.Rasterize = picKml.Rasterize; //globeGraphicsLayer.AddElement(this, properties, out this.index); //flashTimer = new System.Timers.Timer(); //flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); //flashTimer.Interval = 500; }
/// <summary> /// 创建线图元 /// </summary> /// <param name="kml">线的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public IMFElement CreateElement(Kml kml, ILayer layer) { KmlLineString lineKml = kml.Placemark.Graph as KmlLineString; if (lineKml.PositionList == null || lineKml.PositionList.Count < 1) { return(null); } int index = -1; //图层 IGlobeGraphicsLayer graphicLayer = layer as IGlobeGraphicsLayer; if (graphicLayer == null) { return(null); } //图元 Line_ArcGlobe lineElement = null; Dosomething((Action) delegate() { //属性 GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass(); properties.Rasterize = lineKml.Rasterize; //添加图元 lineElement = new Line_ArcGlobe(graphicLayer, lineKml); graphicLayer.AddElement(lineElement, properties, out index); lineElement.Index = index; //指定索引 lineElement.ElementName = kml.Placemark.Name; }, true); return(lineElement); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { if (!m_bConnected) { //show the tracking type selection dialog (whether to track the element from above or follow it from behind) TrackSelectionDlg dlg = new TrackSelectionDlg(); if (System.Windows.Forms.DialogResult.OK != dlg.ShowDialog()) return; //get the required tracking mode m_bTrackAboveTarget = dlg.UseOrthoTrackingMode; //do only once initializations if (m_once) { //create the graphics layer to manage the dynamic object m_globeGraphicsLayer = new GlobeGraphicsLayerClass(); ((ILayer)m_globeGraphicsLayer).Name = "DynamicObjects"; IScene scene = (IScene)m_globeDisplay.Globe; //add the new graphic layer to the globe scene.AddLayer((ILayer)m_globeGraphicsLayer, false); //activate the graphics layer scene.ActiveGraphicsLayer = (ILayer)m_globeGraphicsLayer; //redraw the GlobeDisplay m_globeDisplay.RefreshViewers(); //open a polyline featurelayer that would serve the real-time feed GPS simulator IFeatureLayer featureLayer = GetFeatureLayer(); if (featureLayer == null) return; //assign the featurelayer to the GPS simulator m_realTimeFeedManager.RealTimeFeedSimulator.FeatureLayer = featureLayer; m_once = false; } //get the GlobeViewUtil which is needed for coordinate transformations m_sceneViwer = m_globeDisplay.ActiveViewer; //Set the globe mode to terrain mode, since otherwise it will not be possible to set the target position ((IGlobeCamera)m_sceneViwer.Camera).OrientationMode = esriGlobeCameraOrientationMode.esriGlobeCameraOrientationLocal; //set the simulator elapsed time m_realTimeFeedManager.RealTimeFeedSimulator.TimeIncrement = 0.1; //sec //wire the real-time feed PositionUpdate event ((IRealTimeFeedEvents_Event)m_realTimeFeed).PositionUpdated += new IRealTimeFeedEvents_PositionUpdatedEventHandler(OnPositionUpdated); //start the real-time listener m_realTimeFeed.Start(); } else { //stop the real-time listener m_realTimeFeed.Stop(); //un-wire the PositionUpdated event handler ((IRealTimeFeedEvents_Event)m_realTimeFeed).PositionUpdated -= new IRealTimeFeedEvents_PositionUpdatedEventHandler(OnPositionUpdated); } //switch the connection flag m_bConnected = !m_bConnected; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { if (!m_bConnected) { //show the tracking type selection dialog (whether to track the element from above or follow it from behind) TrackSelectionDlg dlg = new TrackSelectionDlg(); if (System.Windows.Forms.DialogResult.OK != dlg.ShowDialog()) { return; } //get the required tracking mode m_bTrackAboveTarget = dlg.UseOrthoTrackingMode; //do only once initializations if (m_once) { //create the graphics layer to manage the dynamic object m_globeGraphicsLayer = new GlobeGraphicsLayerClass(); ((ILayer)m_globeGraphicsLayer).Name = "DynamicObjects"; IScene scene = (IScene)m_globeDisplay.Globe; //add the new graphic layer to the globe scene.AddLayer((ILayer)m_globeGraphicsLayer, false); //activate the graphics layer scene.ActiveGraphicsLayer = (ILayer)m_globeGraphicsLayer; //redraw the GlobeDisplay m_globeDisplay.RefreshViewers(); //open a polyline featurelayer that would serve the real-time feed GPS simulator IFeatureLayer featureLayer = GetFeatureLayer(); if (featureLayer == null) { return; } //assign the featurelayer to the GPS simulator m_realTimeFeedManager.RealTimeFeedSimulator.FeatureLayer = featureLayer; m_once = false; } //get the GlobeViewUtil which is needed for coordinate transformations m_sceneViwer = m_globeDisplay.ActiveViewer; //Set the globe mode to terrain mode, since otherwise it will not be possible to set the target position ((IGlobeCamera)m_sceneViwer.Camera).OrientationMode = esriGlobeCameraOrientationMode.esriGlobeCameraOrientationLocal; //set the simulator elapsed time m_realTimeFeedManager.RealTimeFeedSimulator.TimeIncrement = 0.1; //sec //wire the real-time feed PositionUpdate event ((IRealTimeFeedEvents_Event)m_realTimeFeed).PositionUpdated += new IRealTimeFeedEvents_PositionUpdatedEventHandler(OnPositionUpdated); //start the real-time listener m_realTimeFeed.Start(); } else { //stop the real-time listener m_realTimeFeed.Stop(); //un-wire the PositionUpdated event handler ((IRealTimeFeedEvents_Event)m_realTimeFeed).PositionUpdated -= new IRealTimeFeedEvents_PositionUpdatedEventHandler(OnPositionUpdated); } //switch the connection flag m_bConnected = !m_bConnected; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="_graphcisLayer">图层</param> /// <param name="lineKml">线的kml</param> public Line_ArcGlobe(IGlobeGraphicsLayer _graphcisLayer, KmlLineString lineKml) { graphcisLayer = _graphcisLayer; this.ElementType = ElementTypeEnum.Line; //图元类型 this.Description = lineKml.Description; //描述 #region 位置 IPolyline polyLine = new PolylineClass(); IPointCollection pointCollection = polyLine as IPointCollection; IPoint p = new PointClass(); foreach (var item in lineKml.PositionList) { p.PutCoords(item.Lng, item.Lat); p.Z = item.Alt; pointCollection.AddPoint(p); } IGeometry geometry = (IGeometry)pointCollection; (geometry as IZAware).ZAware = true; base.Geometry = (IGeometry)pointCollection; #endregion #region 符号 pLineSymbol = new SimpleLineSymbolClass(); if (lineKml.Color.ToArgb() == 0) //符号颜色 { IColor color = new RgbColorClass() { Transparency = Color.Red.A, Red = Color.Red.R, Green = Color.Red.G, Blue = Color.Red.B }; pLineSymbol.Color = color; } else { IColor color = new RgbColorClass() { Transparency = lineKml.Color.A, Red = lineKml.Color.R, Green = lineKml.Color.G, Blue = lineKml.Color.B }; pLineSymbol.Color = color; } if (lineKml.Width == 0) //符号宽度 { lineKml.Width = 2; } pLineSymbol.Width = lineKml.Width; pLineSymbol.Style = (esriSimpleLineStyle)lineKml.LineStyle; //线的样式 base.Symbol = pLineSymbol; #endregion flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 1000; }
public void UpdateAllElement() { IGlobeGraphicsLayer graphicsContainer3D = _layer as IGlobeGraphicsLayer; graphicsContainer3D.UpdateAllElements(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="_graphicsLayer">图层</param> /// <param name="pointKml">点kml</param> public Point_ArcGlobe(IGlobeGraphicsLayer _graphicsLayer, KmlPoint pointKml) { graphicsLayer = _graphicsLayer; this.ElementType = Core.Model.ElementTypeEnum.Point; //图元类型 this.Description = pointKml.Description; //图元描述 #region 位置 IPoint pt = new PointClass(); pt.PutCoords(pointKml.Position.Lng, pointKml.Position.Lat); pt.Z = pointKml.Position.Alt; (pt as IZAware).ZAware = true;//设置高度 base.Geometry = pt; #endregion #region 符号 markerSymbol = new SimpleMarker3DSymbolClass(); //设置颜色 if (pointKml.Color.ToArgb() == 0) { IRgbColor color = new RgbColorClass() { Transparency = 50, Red = Color.Green.R, Green = Color.Green.G, Blue = Color.Green.B }; markerSymbol.Color = color; } else { IRgbColor color = new RgbColorClass() { Transparency = pointKml.Color.A, Red = pointKml.Color.R, Green = pointKml.Color.G, Blue = pointKml.Color.B }; markerSymbol.Color = color; } //设置大小 if (pointKml.Size.Height == 0) { markerSymbol.Size = 500; } else { markerSymbol.Size = pointKml.Size.Height; } markerSymbol.Angle = 90; markerSymbol.Style = (esriSimple3DMarkerStyle)pointKml.PointStyle; base.Symbol = markerSymbol; #endregion flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 3000; isFlash = false; }
/// <summary> /// 构造函数 /// </summary> /// <param name="graphicsLayer">图层</param> /// <param name="kmlCircle">圆的kml</param> public Circle_ArcGlobe(IGlobeGraphicsLayer _graphicsLayer, KmlCircle kmlCircle) { this.ElementType = Core.Model.ElementTypeEnum.Circle; graphicsLayer = _graphicsLayer; lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = new RgbColorClass() { Red = kmlCircle.StrokeColor.R, Green = kmlCircle.StrokeColor.G, Blue = kmlCircle.StrokeColor.B }; if (kmlCircle.StrokeWidth == 0) { kmlCircle.StrokeWidth = 2; } lineSymbol.Width = kmlCircle.StrokeWidth; fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Outline = lineSymbol; fillSymbol.Color = new RgbColorClass() { Red = kmlCircle.FillColor.R, Green = kmlCircle.FillColor.G, Blue = kmlCircle.FillColor.B }; radius = kmlCircle.Radius; outlineColor = kmlCircle.StrokeColor; fillColor = kmlCircle.FillColor; centerPoint = new PointClass();//圆心坐标 centerPoint.PutCoords(kmlCircle.Position.Lng, kmlCircle.Position.Lat); centerPoint.Z = kmlCircle.Position.Alt; missing = System.Type.Missing; IZAware zAware = (IGeometry)centerPoint as IZAware; zAware.ZAware = true; upperAxisVector3D = new Vector3DClass(); upperAxisVector3D.SetComponents(0, 0, 2); lowerAxisVector3D = new Vector3DClass(); lowerAxisVector3D.SetComponents(0, 0, -2); lowerAxisVector3D.XComponent -= vectorComponentOffset; lowerAxisVector3D.YComponent -= vectorComponentOffset;//TODO normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; normalVector3D.Magnitude = kmlCircle.Radius; double rotationAngleInRadians = 2 * (Math.PI / 180); //geometryCollection = new MultiPatchClass(); pointCollection = new PolygonClass(); for (int i = 0; i < 180; i++) { normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); IPoint vertexPoint = new PointClass(); vertexPoint.X = centerPoint.X + normalVector3D.XComponent; vertexPoint.Y = centerPoint.Y + normalVector3D.YComponent; vertexPoint.Z = centerPoint.Z; pointCollection.AddPoint(vertexPoint, missing, missing); } base.Symbol = fillSymbol; base.Geometry = pointCollection as IGeometry; flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 500; }
/// <summary> /// Adds a sphere element to the given graphics layer at the specified position /// </summary> /// <param name="globeGraphicsLayer"></param> /// <param name="position"></param> /// <returns></returns> private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position) { if (null == globeGraphicsLayer) return -1; //create a new point at the given position IPoint point = new PointClass(); ((IZAware)point).ZAware = true; point.X = position.longitude; point.Y = position.latitude; point.Z = 0.0; //set the color for the element (red) IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 0; color.Blue = 0; //create a new 3D marker symbol IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //set the marker symbol's style and resolution ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //set the symbol's size and color markerSymbol.Size = 700; markerSymbol.Color = color as IColor; //crate the graphic element IElement trackElement = new MarkerElementClass(); //set the element's symbol and geometry (location and shape) ((IMarkerElement)trackElement).Symbol = markerSymbol; trackElement.Geometry = point as IPoint; //add the element to the graphics layer int elemIndex = 0; ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0); //get the element's index globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex); return elemIndex; }