zoukankan      html  css  js  c++  java
  • 从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);
       

  • 相关阅读:
    # 2018-2019-1 20165206 《信息安全系统设计基础》第1周学习总结
    20165206 2017-2018-2《Java程序设计》课程总结
    2017-2018-2 20165206 实验五《网络编程与安全》实验报告
    20165206第4次实验《Android程序设计》实验报告
    同源策略、跨域解决方案
    盒子模型,块级元素和行内元素
    http常见错误
    深入理解 JavaScript 事件循环(一)— event loop
    git常用指令
    js 常用方法
  • 原文地址:https://www.cnblogs.com/jetz/p/243606.html
Copyright © 2011-2022 走看看