陌生的不再陌生

导航

Dotspatial 按条件筛选专题图

public static void setColorByCondition(Map mapControl,string filter,string legendText)
{
if (mapControl.Layers.Count > 0)
{
MapPolygonLayer stateLayer = default(MapPolygonLayer);
stateLayer = (MapPolygonLayer)mapControl.Layers[0];
if (stateLayer == null)
{
MessageBox.Show("The layer is not a polygon layer.");
}
else
{
stateLayer.DataSet.FillAttributes();
PolygonScheme scheme = new PolygonScheme();
PolygonCategory category = new PolygonCategory(Color.Yellow, Color.Red, 1);
//filter = "[小班面积] < " + population + "";

category.FilterExpression = filter;
category.LegendText =legendText;// "面积 < " + population.ToString();
scheme.AddCategory(category);

stateLayer.Symbology = scheme;
}
}
else
{
MessageBox.Show("Please add a layer to the map.");
}
}

 

调用方法:

setColorByCondition(mapMain, " [面积] < 20", "面积小于20");

posted on 2020-02-06 14:45  陌生的不再陌生  阅读(299)  评论(0编辑  收藏  举报