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


            如果想要将一个选中的图元强调显示,用红色醒目的文字显示的话,我的思路如下:
                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);
       

  • 相关阅读:
    推荐6款极具个性化的在线生成logo的网站
    网站图标制作
    关于域名如何指向WordPress homepage问题的解决
    WordPress 博客文章中google adsense广告展示方法之一
    WordPress网站搬家经验总结
    WordPress网站搬家的问题
    Linux RAID卡优化
    说说JSON和JSONP,也许你会豁然开朗
    可以嵌入程序的chrome
    maven jetty指定端口启动
  • 原文地址:https://www.cnblogs.com/jetz/p/243606.html
Copyright © 2020-2023  润新知