首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >从MapX到MapXtreme2004[9]-标注的强调显示

从MapX到MapXtreme2004[9]-标注的强调显示

作者头像
用户1075292
发布2018-01-23 10:16:36
6310
发布2018-01-23 10:16:36
举报
文章被收录于专栏:听雨堂听雨堂

        如果想要将一个选中的图元强调显示,用红色醒目的文字显示的话,我的思路如下:             1、不可能直接改原先的图元,所以必须要在一个新的图层上进行操作             2、新的图层因为不同的人用,会放置不同的东西,用固定图层不合适,得用动态生成的图层         碰到很多问题,如下:             1、原来的图层,默认设置了autolabel,所以可以直接显示,但是mapxtreme2004并不支持对图层的autolabel的设置。要想在程序中自动标注,必须得依赖labellayer。             2、用固定的设置好autolabel的图层不行,那么能否动态的将一个设置好autolabel属性的固定层复制成一个动态图层呢?我没有找到图层的clone方法。             3、试验过程中,试过复制图层,在旁边动态创建一个标注文字的方式。但文字随放大缩小变化,很不好快。         最终解决方法:             1、创建一个ShowLayer,同时也创建一个LabelLayer,关联,并设置好显示效果。             2、强调显示时,用Feature.Clone复制图元。但是必须注意,要保证ShowLayer的列与被复制的图元的列一致才行。                3、如果强调点的位置偏移,可以重新调整坐标系。         创建ShowLayer的代码:

   public ShowLayerSys(Map MainMap)
  {
   map=MainMap;
 
   _tempTable=MapInfo.Engine.Session.Current.Catalog.GetTable("ShowLayer");
   if(_tempTable==null)
   {   
    TableInfo ti= TableInfoFactory.CreateTemp("ShowLayer"); // create tableinfo with just obj and style cols
    ti.Columns.Add(new Column("ID",MapInfo.Data.MIDbType.String,50,0));
    ti.Columns.Add(new Column("f_name",MapInfo.Data.MIDbType.String,50,0));
    _tempTable = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
   }
   map.Layers.Insert(0, new FeatureLayer(_tempTable));
   //设置标注层
   LabelLayer layer = new LabelLayer();
   MainMap.Layers.Add(layer);
   LabelSource source = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable("ShowLayer"));
   source.DefaultLabelProperties.Caption = "f_name";
   source.DefaultLabelProperties.Style.Font.ForeColor=System.Drawing.Color.Blue;   //字体颜色
   //source.DefaultLabelProperties.Style.Font.BackColor =System.Drawing.Color.PowderBlue ;   //字体背景
   source.DefaultLabelProperties.Style.Font.TextEffect=MapInfo.Styles.TextEffect.Box;  //边缘效果
   source.DefaultLabelProperties.Style.Font.FontWeight =MapInfo.Styles.FontWeight.Bold ; //粗体
   source.DefaultLabelProperties.Layout.Alignment=MapInfo.Text.Alignment.CenterRight;  //相对位置
   source.DefaultLabelProperties.Layout.Offset=2;
   layer.Sources.Append(source);
  }

       强调显示的代码:

   MapInfo.Styles.SimpleVectorPointStyle  sty=new SimpleVectorPointStyle();
 
   sty.Color=System.Drawing.Color.Blue  ;
   Feature f=(Feature)ftr.Clone();
   f.Style=sty;
   _tempTable.InsertFeature(f);
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2005-09-25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档