예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <summary>
        /// 移除图元
        /// </summary>
        /// <param name="element">要移除的图元对象</param>
        /// <param name="layer">图元所在的图层</param>
        /// <returns></returns>
        public bool RemoveElement(IMFElement element, ILayer layer)
        {
            if (element == null)
            {
                return(true);
            }
            IGraphicsContainer graphicsLayer = layer as IGraphicsContainer;

            if (graphicsLayer == null)
            {
                return(true);
            }

            Polygon_ArcGlobe polygonElement = element as Polygon_ArcGlobe;

            if (polygonElement.Rasterize)
            {
                polygonElement.Rasterize = false;
            }
            graphicsLayer.DeleteElement(polygonElement);

            return(true);
        }