/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图元的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { Core.Model.KmlCircle kmlCircle = kml.Placemark.Graph as Core.Model.KmlCircle; if (kmlCircle == null) { return(null); } if (kmlCircle.Position == null || kmlCircle.Radius <= 0) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Circle_ArcMap circleElement = new Circle_ArcMap(mapControl, kmlCircle, factoryArcMap); circleElement.Opacity = 30; circleElement.ElementType = Core.Model.ElementTypeEnum.Circle; graphicLayer.AddElement(circleElement, 0); return(circleElement); }
/// <summary> ///创建图元 /// </summary> /// <param name="kml"></param> /// <param name="layer"></param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { KmlText kmlText = kml.Placemark.Graph as KmlText; if (kmlText == null) { return(null); } if (kmlText.Position == null) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Text_ArcMap textElement = new Text_ArcMap(mapControl, kmlText, mapFactory); textElement.ElementType = ElementTypeEnum.Text; graphicLayer.AddElement(textElement, 0); return(textElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">面的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { KmlPolygon kmlPolygon = kml.Placemark.Graph as KmlPolygon; if (kmlPolygon == null) { return(null); } if (kmlPolygon.PositionList == null || kmlPolygon.PositionList.Count == 0) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Polygon_ArcMap polygonElement = new Polygon_ArcMap(mapControl, kmlPolygon, mapFoctory); polygonElement.Opacity = 30; graphicLayer.AddElement(polygonElement, 0); polygonElement.ElementType = ElementTypeEnum.Polygon; return(polygonElement); }
/// <summary> /// 创建线图元 /// </summary> /// <param name="kml">线kml对象</param> /// <param name="layerName">图层名称</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, string layerName) { //MapFrame.Core.Model.KmlLineString kmlLine = kml.Placemark.Graph as MapFrame.Core.Model.KmlLineString; Line_Mgis lineMgis = new Line_Mgis(kml, mapControl); //if (kml.Placemark.Name == null || kmlLine.PositionList == null) return null; //int count = kmlLine.PositionList.Count(); //float[] vertex = new float[count * 2]; //IntPtr ptrVert = Marshal.AllocHGlobal(sizeof(float) * count * 2); //for (int i = 0; i < count; i++) //{ // vertex[2 * i] = (float)kmlLine.PositionList[i].Lng; // vertex[2 * i + 1] = (float)kmlLine.PositionList[i].Lat; //} //Marshal.Copy(vertex, 0, ptrVert, vertex.Length); //mapControl.MgsDrawLineSymByJBID(kml.Placemark.Name, 10, (ulong)(ptrVert.ToInt64()), count); //Marshal.FreeHGlobal(ptrVert); //if (kmlLine.Color.ToArgb() != 0) //{ // mapControl.MgsUpdateSymColor(kml.Placemark.Name, kmlLine.Color.R, kmlLine.Color.G, kmlLine.Color.B, kmlLine.Color.A); //} //lineMgis.SetLineName(kml.Placemark.Name); //lineMgis.SetListPoint(kmlLine.PositionList); //lineMgis.ElementType = ElementTypeEnum.Line; return(lineMgis); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图标的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ESRI.ArcGIS.Carto.ILayer layer) { KmlPoint pointKml = kml.Placemark.Graph as KmlPoint; if (pointKml == null) { return(null); } if (pointKml.Position == null) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } PointIco_ArcMap pictureElement = new PointIco_ArcMap(mapControl, pointKml, mapFactory); pictureElement.ElementType = ElementTypeEnum.Picture; graphicLayer.AddElement(pictureElement, 0); return(pictureElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">kml对象</param> /// <param name="layerName">图元名称</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, string layerName) { //MapFrame.Core.Model.KmlCircle kmlCircle = kml.Placemark.Graph as MapFrame.Core.Model.KmlCircle; //Circle_Mgis circleMgis = new Circle_Mgis(kml,mapControl); //if (kmlCircle.Position == null || kmlCircle.RandomPosition == null || kml.Placemark.Name == string.Empty) return null; //List<MapLngLat> listPoints = new List<MapLngLat>(); //listPoints.Add(kmlCircle.Position); //listPoints.Add(kmlCircle.RandomPosition); //float[] vertex = new float[4]; //IntPtr ptrVert = Marshal.AllocHGlobal(sizeof(float) * 4); //vertex[0] = (float)listPoints[0].Lng; //vertex[1] = (float)listPoints[0].Lat; //vertex[2] = (float)listPoints[1].Lng; //vertex[3] = (float)listPoints[1].Lat; //Marshal.Copy(vertex, 0, ptrVert, vertex.Length); //mapControl.MgsDrawLineSymByJBID(kml.Placemark.Name, 16, (ulong)(ptrVert.ToInt64()), 2); //Marshal.FreeHGlobal(ptrVert); //if (kmlCircle.StrokeColor.ToArgb() != System.Drawing.Color.Black.ToArgb() || kmlCircle.FillColor.ToArgb() != 0) //{ // mapControl.MgsUpdateSymFillColor(kml.Placemark.Name, kmlCircle.FillColor.R, kmlCircle.FillColor.G, kmlCircle.FillColor.B, kmlCircle.FillColor.A); // mapControl.MgsUpdateSymColor(kml.Placemark.Name, kmlCircle.StrokeColor.R, kmlCircle.StrokeColor.G, kmlCircle.StrokeColor.B, kmlCircle.StrokeColor.A); //} //circleMgis.SetCircleName(kml.Placemark.Name); //circleMgis.SetListPoint(listPoints); //circleMgis.ElementType = ElementTypeEnum.Circle; Circle_Mgis circleMgis = new Circle_Mgis(kml, mapControl); return(circleMgis); }
/// <summary> /// 创建线图元 /// </summary> /// <param name="kml">线的kml</param> /// <param name="layer">图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { KmlLineString line = kml.Placemark.Graph as KmlLineString; if (line == null) { return(null); } if (line.PositionList == null || line.PositionList.Count < 1) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Line_ArcMap lineElement = new Line_ArcMap(mapControl, line, mapFactory); lineElement.Opacity = 50; lineElement.ElementType = ElementTypeEnum.Line; graphicLayer.AddElement(lineElement, 0); return(lineElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图标的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IElement CreateElement(Core.Model.Kml kml, ESRI.ArcGIS.Carto.ILayer layer) { KmlPicture pictureKml = kml.Placemark.Graph as KmlPicture; if (pictureKml == null) { return(null); } if (pictureKml.Position == null) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Picture_ArcMap pictureElement = new Picture_ArcMap(graphicLayer, pictureKml); pictureElement.ElementType = ElementTypeEnum.Picture; graphicLayer.AddElement(pictureElement, 0); return(pictureElement); }
/// <summary> /// 创建文字图元 /// </summary> /// <param name="km"></param> /// <param name="layerName"></param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml km, string layerName) { //MapFrame.Core.Model.KmlText kmlText = km.Placemark.Graph as MapFrame.Core.Model.KmlText; //Text_Mgis textMgis = new Text_Mgis(mapControl); //if (km.Placemark.Name == null || kmlText.Content == string.Empty) return null; //mapControl.MgsDrawSymTextByJBID(km.Placemark.Name, kmlText.Content,(float)kmlText.Position.Lng, (float)kmlText.Position.Lat); //System.Drawing.Color c = System.Drawing.Color.FromArgb(kmlText.Color); //mapControl.MgsUpdateSymColor(km.Placemark.Name, c.R, c.G, c.B, c.A); //mapControl.MgsUpdateSymSize(km.Placemark.Name, (float)kmlText.Size); //textMgis.SetTextName(km.Placemark.Name); //textMgis.ElementType = Core.Model.ElementTypeEnum.Text; Text_Mgis textMgis = new Text_Mgis(km, mapControl); return(textMgis); }
/// <summary> /// 添加图元 /// </summary> /// <param name="layerName">图元所在的图层名称</param> /// <param name="kml">kml对象</param> /// <returns></returns> public IMFElement AddElement(string layerName, Core.Model.Kml kml) { if (kml == null) { return(null); } if (kml.Placemark == null) { return(null); } if (kml.Placemark.Graph == null) { return(null); } if (string.IsNullOrEmpty(kml.Placemark.Name)) { return(null); } var layer = lyMgr.GetLayer(layerName); if (layer == 0) { return(null); } IElementFactory elementFactory = null; Type type = kml.Placemark.Graph.GetType(); // 点 if (type == typeof(KmlPoint)) { elementFactory = pointFac; } // 线 else if (type == typeof(KmlLineString)) { elementFactory = lineFac; } // 面 else if (type == typeof(KmlPolygon)) { elementFactory = polygonFac; } // 文字 else if (type == typeof(KmlText)) { elementFactory = textFac; } // 圆 else if (type == typeof(KmlCircle)) { elementFactory = circleFac; } else if (type == typeof(KmlPicture)) { elementFactory = pictureFac; } if (elementFactory == null) { return(null); } IMFElement element = elementFactory.CreateElement(kml, layerName); if (element != null) { element.ElementName = kml.Placemark.Name; } return(element); }
/// <summary> /// 添加图元 /// </summary> /// <param name="layerName">图层名称</param> /// <param name="kml">Kml对象</param> /// <returns></returns> public MapFrame.Core.Interface.IMFElement AddElement(string layerName, Core.Model.Kml kml) { if (kml == null) { return(null); } if (kml.Placemark == null) { return(null); } if (kml.Placemark.Graph == null) { return(null); } if (string.IsNullOrEmpty(kml.Placemark.Name)) { return(null); } var layer = lyMgr.GetLayer(layerName); if (layer == null) { return(null); } IElementFactory elementFactory = null; Type type = kml.Placemark.Graph.GetType(); // 点 if (type == typeof(KmlPoint)) { KmlPoint pointKml = kml.Placemark.Graph as KmlPoint; if (pointKml == null) { return(null); } if (string.IsNullOrEmpty(pointKml.IcoUrl))//没有图标纯点 { elementFactory = pointFac; } else //有图标 { elementFactory = pointIcoFac; } } // 线 else if (type == typeof(KmlLineString)) { elementFactory = lineFac; } // 面 else if (type == typeof(KmlPolygon)) { elementFactory = polygonFac; } // 文字 else if (type == typeof(KmlText)) { elementFactory = textFac; } // 圆 else if (type == typeof(KmlCircle)) { elementFactory = circleFac; } if (elementFactory == null) { return(null); } MapFrame.Core.Interface.IMFElement element = elementFactory.CreateElement(kml, layer); if (element != null) { element.ElementName = kml.Placemark.Name; } Refresh(layer as Core.Interface.IMFLayer); return(element); }
public IElement AddElement(string layerName, Core.Model.Kml kml) { throw new NotImplementedException(); }