zoukankan      html  css  js  c++  java
  • Dotspatial 按条件筛选要素

    /// <summary>
    /// 按条件筛选记录
    /// </summary>
    /// <param name="mapControl"></param>
    /// <param name="sqlFilter"></param>
    public static void SelectByAttribute(Map mapControl, string filter)
    {
    if (mapControl.Layers.Count > 0)
    {
    //Declare a MapPolygonLayer
    MapPolygonLayer stateLayer = default(MapPolygonLayer);
    //TypeCast the first layer from MapControl to MapPolygonLayer.
    //Layers are 0 based, therefore 0 is going to grab the first layer from the MapControl
    stateLayer = (MapPolygonLayer) mapControl.Layers[0];
    //Check whether stateLayer is polygon layer or not
    if (stateLayer == null)
    {
    MessageBox.Show("The layer is not a polygon layer.");
    }
    else
    {
    //SelectByAttribute method is used to implement the filter operations.
    //In this example, STATE_NAME is used implement the filter operation
    //We can see the IdhoSate on the map
    stateLayer.SelectByAttribute(filter);
    }
    }
    else
    {
    MessageBox.Show("Please add a layer to the map.");
    }
    }

    调用方法:

    string filter = "[小班号] = '2'";
    SelectByAttribute(mapMain, filter);

  • 相关阅读:
    PhoneGap打包webApp
    mysql触发器实例说明
    mysql索引总结
    python:生成器
    python:装饰器
    python:局部变量与全局变量
    python:函数
    python:文件操作
    python:集合及其运算
    python:字符串常用函数
  • 原文地址:https://www.cnblogs.com/kogame/p/12268646.html
Copyright © 2011-2022 走看看