zoukankan      html  css  js  c++  java
  • Dotspatial 分类专题图专题图

    /// <summary>
    /// 按多条件进行筛选记录,并显示颜色
    /// </summary>
    /// <param name="mapControl">地图控件</param>
    /// <param name="filter">筛选条件</param>
    /// <param name="legendText">图例文本</param>
    public static void ThemeCategory(Map mapControl, string filter, string legendText)
    {
    if (mapControl.Layers.Count > 0)
    {
    //Delacre a MapPolygonLayer
    MapPolygonLayer stateLayer = default(MapPolygonLayer);

    //Type cast the FirstLayer of MapControl to MapPolygonLayer
    stateLayer = (MapPolygonLayer) mapControl.Layers[0];

    //Check the MapPolygonLayer ( Make sure that it has a polygon layer)
    if (stateLayer == null)
    {
    MessageBox.Show("The layer is not a polygon layer.");
    }
    else
    {
    //!!! this line is necessary otherwise the code doesn't work
    //this will load the attribute table of the layer into memory.
    stateLayer.DataSet.FillAttributes();

    //Create a new PolygonScheme
    PolygonScheme scheme = new PolygonScheme();

    //Create a new PolygonCategory
    PolygonCategory category = new PolygonCategory(Color.Yellow, Color.Red, 1);

    //Declare a filter string
    //[POP1990],[STATE_NAME] are attributes from the attribute table of the given shape file.

    //string filter = "[小班面积] <2 AND [林班号] = '3' and [小班号]<3";

    //Set/Assign the filter expression to PolygonCategory
    category.FilterExpression = filter;

    //Set the Legend Text
    category.LegendText = legendText; // "林班号=3";

    //Add the PolygonCategory in to the PolygonScheme
    scheme.AddCategory(category);

    //Set the scheme in to the MapPolygonLayer's symbology
    stateLayer.Symbology = scheme;
    }
    }
    else
    {
    MessageBox.Show("Please add a layer to the map.");
    }
    }

    调用方法:

    //分类专题图专题图
    string filter = "[面积] >2 AND [林班号] = '2'";
    string legendText = "面积>2";
    Lzq_Theme.ThemeCategory(mapMain, filter, legendText);

  • 相关阅读:
    科普下病菌和病毒
    centos环境下安装docker
    change master to到一个不存在的主库或主库无法连接
    java.lang.outofmemoryerror android
    委托 C#
    将PC端的网站转化成手机端网站需要增加以下这段代码即可,再布局一下界面即可
    combobox联动
    删除dataGridview中选中的一行或多行
    vs2010下如何使【“System.Data.OracleClient.OracleConnection”已过时】 解决办法
    MyEclipse连接SQL Server 2008数据库的操作方法
  • 原文地址:https://www.cnblogs.com/kogame/p/12268657.html
Copyright © 2011-2022 走看看