/// <summary> /// 移除线图元 /// </summary> /// <param name="element">要移除的线图元</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public bool RemoveElement(IMFElement element, ILayer layer) { GlobeGraphicsLayerClass graphicLayer = layer as GlobeGraphicsLayerClass; if (graphicLayer == null) { return(false); } Line_ArcGlobe line = element as Line_ArcGlobe; if (line == null) { return(false); } if (line.Rasterize) //判断图元是否栅格化,栅格化之后删不掉图元,所以要先不栅格化 { line.Rasterize = false; } Dosomething((Action) delegate() { graphicLayer.DeleteElement(line);//删除线图元 }, true); return(true); }
/// <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); }