我如何添加功能自定义层在Dotspatial

本文关键字:自定义 功能 Dotspatial 添加 何添加 | 更新日期: 2023-09-27 18:05:18

我需要为用户在组合框中选择图层名称的自定义图层添加点,线或多边形的特征类型。目前,每个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;
    }`

我如何添加功能自定义层在Dotspatial

我找到了我们应该修改mappointment layer

第一个找到层索引selecteindex = map1.Layers.IndexOf(item);然后将其设置在地图点图层

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