【问题标题】:How can i add feature to custom Layer in Dotspatial?如何在 Dotspatial 中向自定义图层添加功能?
【发布时间】:2016-09-01 06:32:59
【问题描述】:

我需要将要素类型作为点、线或多边形添加到用户在组合框中选择图层名称的自定义图层。 目前,每个 Feature 都只是插入到最后一层制作

这是我的代码:

public void test(Coordinate coord,string ftype)
{

        foreach (var item in map1.Layers)
        {
            if (item.LegendText ==ftype)
            {
                int selectedIndex = map1.Layers.IndexOf(item);
                ((Legend)map1.Legend).ClearSelection();
                map1.Layers[selectedIndex].IsSelected = true;
                map1.Layers.SelectedLayer = map1.Layers[selectedIndex];
                map1.Legend.RefreshNodes();
                label1.Text = Convert.ToString(selectedIndex);
            }

        }
        DotSpatial.Topology.Point point = new DotSpatial.Topology.Point(coord);
        IFeatureSet ifs = new FeatureSet(FeatureType.Point);
        IFeature currentFeature = ifs.AddFeature(point);
        DotSpatial.Symbology.CharacterSymbol pcs = new DotSpatial.Symbology.CharacterSymbol('o', "Webdings", Color.Black, 32);
        DotSpatial.Symbology.PointCategory pc = new DotSpatial.Symbology.PointCategory(pcs);
        pc.Symbolizer.ScaleMode = ScaleMode.Simple;
        pointScheme.AddCategory(pc);
        mpl.Symbology = pointScheme;
        mpl.ApplyScheme(pointScheme);
        _tempLayer = mpl;
        map1.MapFrame.DrawingLayers.Add(mpl);
        map1.MapFrame.Invalidate();
        map1.Invalidate();
        pointID++;
        map1.FunctionMode = FunctionMode.None;

    }`

【问题讨论】:

    标签: c# gis developer-tools feature-selection dotspatial


    【解决方案1】:

    我找到了 我们应该改变 Mappointlayer

    第一个找到的 indexof 层 selectedIndex = map1.Layers.IndexOf(item); 然后设置在地图点图层上

                    mpl= (MapPointLayer)map1.Layers[selectedIndex];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-07
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 2022-01-22
      相关资源
      最近更新 更多