示例#1
0
 public void Render(RenderArgs arg)
 {
     if (_locIcons == null || _locIcons.Count == 0)
     {
         return;
     }
     if (_img == null)
     {
         CreateBackgroudImage();
     }
     using (Font font = new Font("微软雅黑", 9))
     {
         ICoordinateTransform tran = (_mapRuntime as IFeatureRenderEnvironment).CoordinateTransform;
         foreach (LocationIcon icon in _locIcons)
         {
             if (icon == null || string.IsNullOrEmpty(icon.Text) || icon.Feature == null)
             {
                 continue;
             }
             SizeF      fontsize = arg.Graphics.MeasureString(icon.Text, font);
             ShapePoint prjpt    = GetLocationByFeature(icon.Feature);
             PointF[]   pts      = tran.PrjCoord2PixelCoord(new ShapePoint[] { prjpt });
             pts[0].Y -= (_iconSize.Height + 5);
             pts[0].X -= _iconSize.Width / 2;
             arg.Graphics.DrawImage(_img, pts[0]);
             arg.Graphics.DrawString(icon.Text, font, Brushes.Red, pts[0].X + (_iconSize.Width - fontsize.Width) / 2, pts[0].Y - (_iconSize.Height - fontsize.Height) / 2);
         }
     }
 }