Example #1
0
        /// <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);
        }
Example #2
0
        /// <summary>
        /// 添加点图元
        /// </summary>
        /// <param name="kml">kml对象</param>
        /// <param name="gmapOverlay">图层</param>
        /// <returns></returns>
        public Core.Interface.IMFElement CreateElement(Kml kml, global::GMap.NET.WindowsForms.GMapOverlay gmapOverlay)
        {
            if (overlay == null)
            {
                overlay = gmapOverlay;
                overlay.Control.OnMarkerEnter += Control_OnMarkerEnter;
                overlay.Control.OnMarkerLeave += Control_OnMarkerLeave;
            }

            KmlPicture kmlPicture = kml.Placemark.Graph as KmlPicture;

            if (kmlPicture == null)
            {
                return(null);
            }
            if (kmlPicture.Position == null)
            {
                return(null);
            }

            PointLatLng p = new PointLatLng(kmlPicture.Position.Lat, kmlPicture.Position.Lng, kmlPicture.Position.Alt);

            // 位置和图片
            Picture_GMap moveObj = new Picture_GMap(p, kmlPicture, kml.Placemark.Name);

            // Tip
            if (!string.IsNullOrEmpty(kmlPicture.TipText))
            {
                moveObj.ToolTipText = kmlPicture.TipText;
                moveObj.ToolTipMode = MarkerTooltipMode.OnMouseOver;
                moveObj.ToolTip.Format.Alignment = System.Drawing.StringAlignment.Near; // Tip文字左对齐
            }

            // 添加图元到图层
            if (gmapOverlay.Control.InvokeRequired)
            {
                gmapOverlay.Control.BeginInvoke(new Action(delegate
                {
                    gmapOverlay.Markers.Add(moveObj);
                }));
            }
            else
            {
                gmapOverlay.Markers.Add(moveObj);
            }

            return(moveObj);
        }
Example #3
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="kml">图片kml</param>
        /// <param name="layerName">图层名称</param>
        /// <returns></returns>
        public IMFElement CreateElement(Kml kml, string layerName)
        {
            KmlPicture   kmlPicture = kml.Placemark.Graph as KmlPicture;
            Picture_Mgis pointMgis  = new Picture_Mgis();

            if (kmlPicture.Position == null)
            {
                return(null);
            }
            ulong moveObj = 0;

            if (!string.IsNullOrEmpty(kmlPicture.IconUrl))//图片型目标
            {
                moveObj = mapControl.createImageMoveObject(kmlPicture.IconUrl, layerName);
                if (kmlPicture.IconColor.ToArgb() != 0)
                {
                    mapControl.setMoveObjectColor(moveObj, kmlPicture.IconColor.R, kmlPicture.IconColor.G, kmlPicture.IconColor.B, kmlPicture.IconColor.A);//设置目标颜色
                }
            }
            else //字体型目标
            {
                if (kmlPicture.IconColor.ToArgb() == 0)
                {
                    mapControl.setMoveObjectColor(moveObj, Color.Blue.R, Color.Blue.G, Color.Blue.B, Color.Blue.A);//设置目标颜色
                }
                else
                {
                    mapControl.setMoveObjectColor(moveObj, kmlPicture.IconColor.R, kmlPicture.IconColor.G, kmlPicture.IconColor.B, kmlPicture.IconColor.A);//设置目标颜色
                }
                moveObj = mapControl.createMoveObject(kmlPicture.FontPath, kmlPicture.Code, layerName);
            }
            mapControl.setMoveObjectPositon(moveObj, kmlPicture.Position.Lng, kmlPicture.Position.Lat, 1); //设置目标位置
            mapControl.setMoveObjectScale(moveObj, kmlPicture.Scale, kmlPicture.Scale);                    //设置目标大小
            if (!string.IsNullOrEmpty(kmlPicture.Description))
            {
                mapControl.setMoveObjectTrackUserData(moveObj, kmlPicture.Description);
            }
            mapControl.setMoveObjectProperty(moveObj, "名称", kml.Placemark.Name);
            pointMgis.SetMoveObj(moveObj);

            return(pointMgis);
        }
Example #4
0
        ///// <summary>
        ///// 构造函数,没传图片的情况,用GDI绘制点
        ///// </summary>
        ///// <param name="pos">位置</param>
        ///// <param name="kmlPoint">点的kml对象</param>
        ///// <param name="elementName">图元名称</param>
        //public Picture_GMap(PointLatLng pos, KmlPoint kmlPoint, string elementName)
        //    : base(pos)
        //{
        //    this.ElementName = elementName;
        //    this.Description = kmlPoint.Description;
        //    this.ElementType = ElementTypeEnum.Picture;
        //    // 鼠标经过可见
        //    base.IsHitTestVisible = true;
        //    // 画笔
        //    mHightLightPen = new Pen(Brushes.Green, 1);
        //    mPen = new Pen(kmlPoint.Color, 2);

        //    // 图标
        //    if (!string.IsNullOrEmpty(kmlPoint.IcoUrl))
        //    {
        //        LoadBitmap(kmlPoint.IcoUrl);
        //    }

        //    // 图标缩放比列
        //    if (kmlPoint.Size != null)
        //    {
        //        mScale = kmlPoint.Size.Width;
        //    }

        //    FlashPen = new Pen(Brushes.Red, 3);
        //    mSelfPen = new Pen(Color.Red, 2);
        //    flashTimer.Interval = 100;
        //    flashTimer.Elapsed += flashTimer_Elapsed;
        //    bIsFlash = false;

        //    base.Tag = this;
        //}

        /// <summary>
        /// 构造函数,没传图片的情况,用GDI绘制点
        /// </summary>
        /// <param name="pos">位置</param>
        /// <param name="kmlPicture">点的kml对象</param>
        /// <param name="elementName">图元名称</param>
        public Picture_GMap(PointLatLng pos, KmlPicture kmlPicture, string elementName)
            : base(pos)
        {
            this.ElementName = elementName;
            this.Description = kmlPicture.Description;
            this.ElementType = ElementTypeEnum.Picture;
            // 鼠标经过可见
            base.IsHitTestVisible = true;

            // 画笔
            mHightLightPen = new Pen(Brushes.Green, 1);
            mScale         = kmlPicture.Scale;

            if (kmlPicture.IconColor != null)
            {
                mPen = new Pen(kmlPicture.IconColor, 2);
            }
            else
            {
                mPen = new Pen(Color.Red, 2);
            }

            // 图标
            if (!string.IsNullOrEmpty(kmlPicture.IconUrl))
            {
                LoadBitmap(kmlPicture.IconUrl);
            }

            FlashPen            = new Pen(Brushes.Red, 3);
            mSelfPen            = new Pen(Color.Red, 2);
            flashTimer.Interval = 100;
            flashTimer.Elapsed += flashTimer_Elapsed;
            bIsFlash            = false;

            base.Tag = this;
        }